Summary#
Qualify the pagehide listener registration with window.addEventListener.
This ensures the correct receiver is used when EventTarget.prototype.addEventListener has been patched by instrumentation libraries.
A regression assertion was added to verify that the pagehide listener is registered with window as its context.
Fixes #8024
Tests#
pnpm nx run @tanstack/router-core:test:unit -- tests/scroll-restoration.test.ts
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
- **Bug Fixes**
- Improved scroll restoration reliability by ensuring page navigation events are registered on the browser window.
- **Tests**
- Added coverage confirming the scroll restoration listener is attached to the correct browser target.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Note
Currently processing new changes in this PR. This may take a few minutes, please wait...
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID:
740f6369-21a4-4886-aeb2-1b01a8f08bf1📥 Commits
Reviewing files that changed from the base of the PR and between af8dcb859a2e025740524b267d89da970d65af28 and f20e66ad24865050c97724bb50d076b6ff899075.
📒 Files selected for processing (2)
packages/router-core/src/scroll-restoration.tspackages/router-core/tests/scroll-restoration.test.ts✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share