Message List: Fix stuck date indicator (#5325)

This commit is contained in:
zubiden 2024-12-20 11:37:20 +01:00 committed by Alexander Zinchuk
parent 984a058e38
commit fafbfd9cfc

View File

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