Skip to content

Commit da43bb9

Browse files
poc
1 parent 54f34ee commit da43bb9

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

apps/meteor/client/views/room/MessageList/MessageList.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,12 @@ export const MessageList = function MessageList({
125125
}
126126

127127
// Initial-load scroll-to-end: execute as soon as the scroll element is measured.
128-
// scrollOffset === null means the element isn't ready yet — keep the flag and wait.
129-
// Doing this here (rather than in a useEffect) guarantees the element is available
130-
// and prevents onChange from cascading into spurious getMore calls before we've scrolled.
128+
// scrollRect === null means the element hasn't been observed yet — keep the flag and wait.
129+
// We deliberately check scrollRect (not scrollOffset) because initialOffset: Infinity sets
130+
// scrollOffset = Infinity from birth, so scrollOffset !== null would fire before the DOM
131+
// element is actually available, making scrollToIndex a silent no-op and clearing the flag.
131132
if (shouldScrollToEndRef.current) {
132-
if (scrollOffset !== null && ctx.messages.length > 0) {
133+
if (scrollRect !== null && ctx.messages.length > 0) {
133134
instance.scrollToIndex(ctx.messages.length - 1, { align: 'end' });
134135
shouldScrollToEndRef.current = false;
135136
}

0 commit comments

Comments
 (0)