fix: added scroll preservation opt in to the compare page#2101
fix: added scroll preservation opt in to the compare page#2101graphieros merged 5 commits intonpmx-dev:mainfrom
Conversation
…pdates resetting it
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds opt-in scroll preservation for query-only navigations. A new PageMeta flag Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
test/unit/app/router.options.spec.ts (1)
22-53: Add explicit query-delta coverage for opt-in boundaries.Current tests cover the happy path, but they don’t explicitly assert that only opted-in same-path query updates preserve scroll. Add:
- a same-path/hash test with different
queryvalues andpreserveScrollOnQuery: true(expectfalse), and- the same setup without opt-in (expect
{ left: 0, top: 0 }).As per coding guidelines, "Write unit tests for core functionality using
vitest".
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8d6f7f28-413e-447b-95ff-f530354c64b4
📒 Files selected for processing (3)
app/pages/compare.vueapp/router.options.tstest/unit/app/router.options.spec.ts
graphieros
left a comment
There was a problem hiding this comment.
Works like a charm
LGTM
app/router.options.ts
Outdated
There was a problem hiding this comment.
nit: _ prefix is for unused vars
| scrollBehavior(to, from, savedPosition) { |
🔗 Linked issue
resolves #2098
🧭 Context
Fixes the compare page jumping back to the top when compare state is updated on the page.
On /compare, both package selection and facet selection sync state into the route query, being treated like normal navigations by the router scroll behavior, which caused the page to reset. This change makes scroll preservation opt-in at the page level and enables it for the compare page, so query-only updates keep the current scroll position.
Do note that this does not change normal page-to-page navigation scroll behavior, hash scrolling, or back/forward saved-position restoration.
I basically changed two files and added one test:
preserveScrollOnQuery: trueto the compare page metaI wanted to implement this in a clean way that fixes both affected compare controls with one router-level change:
I wanted to avoid duplicating special-case URL update logic in multiple compare components/composables, and thus keep the behavior scoped to pages that explicitly opt in.
Screen.Recording.2026-03-16.at.13.55.35.mov