Don't scroll page to top when opening or closing a side modal - #3336
Open
david-crespo wants to merge 1 commit into
Open
Don't scroll page to top when opening or closing a side modal#3336david-crespo wants to merge 1 commit into
david-crespo wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Closes #3321
Because side modals get their own routes, and the scroll height cache is keyed (in part) by route, opening a side modal counts as a new page with no saved scroll height, so it scrolls the document to top. The fix is to handle the modal scenario specially by opting out of resetting scroll when we switch to a new location that has the same underlying page path as the previous one.
2026-08-18-scroll-height-fix.mp4
Example flows
Each of these scenarios is covered by e2e tests.
The underlying "page path" for a location is the path of the last non-
titleOnlycrumb, i.e., where the nav breadcrumbs point: a regular page's own path, or for a side modal, the path of the page under it. When a nav starts, we save the current scroll under the outgoing location's key. When it completes, if the page path changed we scroll to the new location's cached position (0 if none); if it didn't (side modal open/close), we leave the scroll alone and just record it under the new key so back/forward still works.Normal page → page nav (
…/disks→…/snapshots, then back)…/disks(k1)…/disks…/disks(k1)…/disks…/snapshots(k2)…/snapshots…/snapshots(k2)…/snapshots…/disks(k1)…/disksPage → modal → page (open the New disk form, then dismiss it)
…/disks(k1)…/disks…/disks(k1)…/disks…/disks-new(k2)…/disks…/disks-new(k2)…/disks…/disks(k3)…/disksModal submit → new page (create a VPC, land on VPC detail page)
…/vpcs-new(k2)…/vpcs…/vpcs-new(k2)…/vpcs…/vpcs/my-vpc(k3)…/vpcs/my-vpc