fix autoscroll issue due to stale scrollableMap#815
Merged
cehan-Chloe merged 5 commits intomainfrom Mar 13, 2026
Merged
Conversation
Bundle ReportChanges will increase total bundle size by 1.22kB (0.02%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: plugins/auto-scroll/reactAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #815 +/- ##
===========================
===========================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…into autoscroll-fix
KetanReddy
approved these changes
Mar 13, 2026
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.
Root cause:
Page1 has autoscroll enabled. scrollableMap was never cleared on view transition from page1 to page2. When navigating to page 2, page 1's registered element IDs remained in the map. Duringthe React transition window — before page 1 components unmount — useEffect fired with stale page 1 IDs, found those elements still in the DOM, and called scrollIntoViewWithOffset. A concurrent window.scroll(0,0) from the player lifecycle fired mid-animation, causing the smooth scroll polyfill to land at the wrong position
Debug observation:
during transition, window.scroll(0,0) is called to reset position but meanwhile the autoscroll useEffect traversed the stale scrollableMaps and triggered multiple scroll animations. only stops until react unmount the page1 components and node is null then no further scroll.
fix:
Clear scrollableMap when a view transition fires, so stale registrations can't trigger scrolls on the new page. Wired this up via an onMount callback from AutoScrollProvider to the plugin's transition hook.
alternative considered: add setTimeout to the auto-scroll useEffect to make sure scroll triggers after react render.
Change Type (required)
Indicate the type of change your pull request is:
patchminormajorN/ADoes your PR have any documentation updates?