Fix smooth scrolling + add scroll on reply click #1326
Merged
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.
Demo
CleanShot.2023-04-04.at.21.11.32-converted.mp4
Explanation
react-virtualized
(which I based our WindowedList component on) is fucked. It doesn’t support our use case with chat. I got smooth bottom-up scrolling working with CSS hackery, but not together with programmatic scroll to arbitrary row. The bottom line is that thereact-virtualized
algorithm is fundamentally a mismatch for the chat use-case, it was built for grids. The author even testified to this and that he won’t have time to fix it (issue still open).Luckily there is another virtualization library built for chat, which out of the box supports:
It’s called
react-virtuoso
and I’ve implemented it in this PR. Long term we might want to rebuild a new WindowedList based on it, but I can’t justify the time spend for it now.All in all, scrolling UX is excellent now.
Side note: I've left the scrollbar visible on all lists. I thought it was helpful UI, but if you think it's ugly @drunkplato it's an easy removal.