Skip to content

[fix] ScrollView: cancel pending scroll-end callback on unmount - #2968

Open
charan-rathore wants to merge 1 commit into
necolas:masterfrom
charan-rathore:fix/scrollview-unmount-timer
Open

charan-rathore wants to merge 1 commit into
necolas:masterfrom
charan-rathore:fix/scrollview-unmount-timer

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant