Repository navigation
[fix] ScrollView: cancel pending scroll-end callback on unmount - #2968
Open
charan-rathore wants to merge 1 commit into
Open
charan-rathore wants to merge 1 commit into
charan-rathore wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
ScrollViewBase schedules a trailing onScroll call 100 ms after the last scroll event. Removing the ScrollView during that delay leaves the timer running, so the callback fires after unmount. In Chrome it can report a zero offset from the detached element after the earlier scroll event reported the actual offset.
Clear the pending timer when the effect cleans up and reset the scrolling state. The timeout remains local to each ScrollView. Mounted scrolling and the final trailing event are unchanged.
Add public ScrollView regressions for unmount, repeated scrolling under StrictMode, independent views, and the mounted trailing event. With the same tests on unchanged master: 3 fail, 10 pass. With the fix: 13 pass.
Checked with real Chrome wheel input: removing the view from the first callback, or closing it before the delay, no longer produces a second callback. The mounted control still reports both events at the scrolled offset. Full npm test passes: Flow, formatting, lint, 55 suites, 811 tests and 201 snapshots; 6 tests remain skipped. npm run build also passes.
This only fixes pending scroll-end work during ordinary unmount. It does not change callback replacement behavior or claim a new concurrent-rendering timing guarantee.