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; }); }