From fafbfd9cfc06c681e62b0fbe52aa842a13db6101 Mon Sep 17 00:00:00 2001 From: zubiden <19638254+zubiden@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:37:20 +0100 Subject: [PATCH] Message List: Fix stuck date indicator (#5325) --- src/components/middle/hooks/useStickyDates.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/middle/hooks/useStickyDates.ts b/src/components/middle/hooks/useStickyDates.ts index c96043afb..ff2fe52e0 100644 --- a/src/components/middle/hooks/useStickyDates.ts +++ b/src/components/middle/hooks/useStickyDates.ts @@ -25,11 +25,6 @@ export default function useStickyDates() { runDebounced(() => { const stuckDateEl = findStuckDate(container); - if (stuckDateEl) { - requestMutation(() => { - stuckDateEl.classList.add('stuck'); - }); - } requestMutation(() => { const currentStuck = document.querySelector('.stuck'); @@ -37,6 +32,10 @@ export default function useStickyDates() { currentStuck.classList.remove('stuck'); } + if (stuckDateEl) { + stuckDateEl.classList.add('stuck'); + } + document.body.classList.remove('is-scrolling-messages'); }); }); @@ -58,6 +57,6 @@ function findStuckDate(container: HTMLElement) { return Array.from(allElements).find((el) => { const { offsetTop, offsetHeight } = el; const top = offsetTop - containerTop; - return -offsetHeight <= top && top <= (headerActionsHeight || STICKY_TOP); + return -offsetHeight <= top && top <= headerActionsHeight + STICKY_TOP; }); }