fix: autoscrolling while ctx menu is active#3617
Merged
Merged
Conversation
Contributor
SDK Size
|
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.
🎯 Goal
This PR addresses an issue with autoscrolling behaviour with our context menu, where view positioning would be offset if we have the context menu open and we receive new messages (and are near the bottom).
Typically, since the
Messageposition would change the context menu would not really have the correct position to crawl back to when we want to animate back. While this can be easily solved through another correctionSharedValue(in order to simply adjust positioning), it is in fact not so trivial to solve the fact that if we receive enough messages (i.e anything past the virtualization window ofFlatListor even worse, enforcing recycling forFlashList) it is very possible that theMessagewe have in the context menu would either be unmounted (or again worse, recycled) and thePortalwould detach from its host. This is very possible within a livestream scenario, for example - where it's not uncommon to receive 10s or 100s of messages in a relatively short timespan.Instead, we simply disable autoscrolling when the context menu is opened. This is still performant because internally, even though a prop changed
FlatListis going to simply disable autoscrolling native side rather than do heavy rerendering internally (basically just the shell). This works similarly forFlashListas well.This generally makes sense from a UX perspective as well, as typically when we want to do a message action we don't particularly want to lose the context of that message's surroundings either (this is how Twitch chat does it as well, for example).
🛠 Implementation details
🎨 UI Changes
iOS
Android
🧪 Testing
☑️ Checklist
developbranch](https://github.com/GetStream/stream-chat-react-native/issues)` `