Skip to content

fix autoscroll issue due to stale scrollableMap#815

Merged
cehan-Chloe merged 5 commits intomainfrom
autoscroll-fix
Mar 13, 2026
Merged

fix autoscroll issue due to stale scrollableMap#815
cehan-Chloe merged 5 commits intomainfrom
autoscroll-fix

Conversation

@cehan-Chloe
Copy link
Copy Markdown
Contributor

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:

  • patch
  • minor
  • major
  • N/A

Does your PR have any documentation updates?

  • Updated docs
  • No Update needed
  • Unable to update docs

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 12, 2026

Bundle Report

Changes will increase total bundle size by 1.22kB (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
plugins/auto-scroll/react 19.67kB 1.22kB (6.64%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: plugins/auto-scroll/react

Assets Changed:

Asset Name Size Change Total Size Change (%)
cjs/index.cjs 420 bytes 7.99kB 5.55% ⚠️
index.legacy-esm.js 402 bytes 5.84kB 7.39% ⚠️
index.mjs 402 bytes 5.84kB 7.39% ⚠️

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (de05e81) to head (7cc4366).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #815   +/-   ##
===========================
===========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cehan-Chloe cehan-Chloe changed the title fix autoscroll on non-autoscroll page fix autoscroll issue due to stale scrollableMap Mar 12, 2026
@cehan-Chloe cehan-Chloe marked this pull request as ready for review March 12, 2026 16:30
@cehan-Chloe cehan-Chloe requested a review from a team as a code owner March 12, 2026 16:30
@cehan-Chloe cehan-Chloe merged commit 4bd1bf4 into main Mar 13, 2026
15 checks passed
@cehan-Chloe cehan-Chloe deleted the autoscroll-fix branch March 13, 2026 17:40
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.

2 participants