Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nx-dev): improve auto-scrolling so it does not interfere with users reading the content #19196

Merged
merged 1 commit into from Sep 15, 2023

Conversation

jaysoo
Copy link
Member

@jaysoo jaysoo commented Sep 15, 2023

This PR improves auto-scrolling, so we check if the user is close to the bottom of the content before scrolling them down. It prevents problems where users can lose the position of where they are reading.

Drastically improves the mobile experience as well where the screen no longer jumps around all the time when typing or reading.

Before:

before.mp4

After:

after.mp4

@vercel
Copy link

vercel bot commented Sep 15, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 15, 2023 6:55pm

if (messages.length > currentMessagesLength.current) {
currentMessagesLength.current = messages.length;
shouldScroll = true;
} else if (el.scrollTop + el.clientHeight + 50 >= el.scrollHeight) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 50?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's exactly the scrollHeight then it's hard for user to scroll to the bottom fast enough and re-enable auto-scroll. The 50 pixels (about two lines of text) seem to work well enough on both desktop and mobile.

@jaysoo jaysoo merged commit b14cd1c into nrwl:master Sep 15, 2023
15 checks passed
@jaysoo jaysoo deleted the ai-chat/fix-scrolling branch September 15, 2023 19:52
@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants