fix: auto-scroll to new message when inverted is false (#2612)#2745
Merged
Conversation
A non-inverted message list appends new messages off-screen at the end and never scrolled to reveal them (inverted lists keep the newest message visible on their own). Track the latest message and, when it changes in a non-inverted list, scroll to the bottom - but only when the user is already near the bottom, so it doesn't yank them away while reading earlier messages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2612
Problem
With
isInverted={false}, new messages are appended to the end of the list but it never scrolls to reveal them, so incoming/sent messages stay off-screen. (Inverted lists don't have this issue - they keep the newest message visible automatically.)Fix
Track the latest message id; when it changes in a non-inverted list, scroll to the bottom. Gated on the user already being near the bottom, so it doesn't yank someone away while they're reading earlier messages - matching how the inverted list behaves.
Validation
Built the example with
isInverted={false}and sent messages on both simulators:tsc,eslint, andbuildpass locally; CI (Node 22 & 24) gates this PR.