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

fix(MessagesList): correctly handle scrollTop position #11460

Merged
merged 1 commit into from
Jan 28, 2024

Conversation

Antreesy
Copy link
Contributor

☑️ Resolves

  • Fix weird message scrolling (hopefully, last time)

Important

It's better to give it a try with a compiled Talk Desktop + c.nc to see if we'll backport it (and how far)

Explanation:

If you don't manipulate numbers directly and only add items to the chat list, the scroll position (scrollTop) will be automatically adjusted based on the added height of the new content.
When the scrollTop value is 0 (at the top of the scrollable area), adding new items at the top will not change the scroll position. The browser will automatically adjust the scroll position to maintain the view at the same position relative to the newly added items. In this case, the new scrollTop value will also be 0 since the content was added at the top and the scroll position was already at the top.
However, if the scrollTop value is non-zero (not at the top), adding new items at the top will increase the overall height of the content, and the browser will adjust the scroll position to maintain the view at the same position relative to the newly added items. The new scrollTop value will be adjusted based on the added height to ensure that the same content remains in view.
This automatic adjustment of the scrollTop value is a built-in behavior of the browser when manipulating the content inside a scrollable container. It ensures that the user's scroll experience remains smooth and consistent, regardless of the changes made to the content.

🖌️ UI Checklist

  • 🌏 Tested with Chrome, Firefox and Safari or should not be risky to browser differences
  • ⛑️ Tests are included or not possible

Copy link
Contributor

@DorraJaouad DorraJaouad left a comment

Choose a reason for hiding this comment

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

It makes sense.
Tested on Talk-desktop c.nc.

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
@Antreesy
Copy link
Contributor Author

Found some quirks with conditions, so returned to original approach, but with old scrollTop value
Tested with Desktop as well

@Antreesy Antreesy merged commit 63d0481 into main Jan 28, 2024
36 checks passed
@Antreesy Antreesy deleted the fix/noid/fix-chat-scrolling branch January 28, 2024 14:59
@Antreesy
Copy link
Contributor Author

/backport to stable28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants