File tree Expand file tree Collapse file tree
apps/meteor/client/views/room/MessageList Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments