prevent scroll top cache when timeline is loading

This commit is contained in:
Ajay Bura committed 2026-10-31 10:04:56 +05:30
1 parent 83979fb313
commit 37dbf1f9bb
1 file changed
+4 -1
+4 -1
View File
@@ -144,12 +144,15 @@ export const useTimelineScrollRestore = (
const batch = timeline.batch.read;
if (typeof scrollTop === 'number') {
scrollEl.scrollTo({ top: scrollTop, behavior: 'instant' });
} else if (batch.next.end && batch.messages.events.length > 0) {
} else if (batch.next.end && batch.size > 0) {
scrollToBottom(scrollEl, 'instant');
}
}
return () => {
if (!scrollEl) return;
const batch = timeline.batch.read;
// do not set cache if event are not loaded yet.
if (batch.size === 0) return;
// eslint-disable-next-line no-param-reassign
timeline.range.scrollTopCache = scrollEl.scrollTop;
};