fix: preserve scroll position after SSR hash hydration#7066
fix: preserve scroll position after SSR hash hydration#7066schiller-manuel merged 2 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughPrevents re-running hash scroll after SSR hydration by marking the router's resolved location when hydration skips a load; adds E2E routes and tests reproducing the hash-scroll scenario. Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant SSRClient
participant Router
participant PreloadService
Browser->>SSRClient: Hydrate (initial load)
SSRClient->>Router: determine if router.load() needed
alt skip router.load()
SSRClient->>Router: set resolvedLocation = location.state
end
Note right of Router: resolvedLocation marked as resolved
Browser->>PreloadService: Hover / Invalidate triggers
PreloadService->>Router: check if location changed vs resolvedLocation
alt location unchanged
Router-->>Browser: skip hash scroll / no re-run
else location changed
Router->>Browser: perform navigation / hash scroll
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
View your CI Pipeline Execution ↗ for commit 66b7228
☁️ Nx Cloud last updated this comment at |
🚀 Changeset Version Preview1 package(s) bumped directly, 21 bumped as dependents. 🟩 Patch bumps
|
Bundle Size Benchmarks
Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@e2e/react-start/scroll-restoration/tests/hash-scroll-repro.spec.ts`:
- Around line 44-50: The response listener is registered after triggering the
hover, causing a race where the preload response may be missed; move the
waitForResponse registration before calling
page.getByTestId('hash-scroll-about-link').hover() so the predicate that checks
response.url().includes('/hash-scroll-about') && response.ok() is listening
prior to the hover action; ensure you register the listener
(page.waitForResponse with the same predicate) and only then trigger
page.getByTestId('hash-scroll-about-link').hover() to avoid intermittent test
failures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 07b86e88-9900-4628-bf58-b3c27f3e55ca
📒 Files selected for processing (7)
.changeset/fair-buckets-learn.mde2e/react-start/scroll-restoration/src/routeTree.gen.tse2e/react-start/scroll-restoration/src/routes/(tests)/hash-scroll-about.tsxe2e/react-start/scroll-restoration/src/routes/(tests)/hash-scroll-repro.tsxe2e/react-start/scroll-restoration/src/routes/__root.tsxe2e/react-start/scroll-restoration/tests/hash-scroll-repro.spec.tspackages/router-core/src/ssr/ssr-client.ts
Summary by CodeRabbit
New Features
Bug Fixes
Tests