You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5e1f767
Browse filesBrowse the repository at this point in the historyBrowse files
Don't scroll page to top when opening or closing a side modal (#3336)
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.
https://github.com/user-attachments/assets/af40dae5-7065-4599-be55-a9dd7ae7299e
### 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-`titleOnly` crumb, 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)
| Step | Location | Page path | Cache | Scroll |
| ----------------------------------------------------- |
------------------ | ------------- | -------------- | ------- |
| Scroll the disks page | `…/disks` (k1) | `…/disks` | | 143 |
| Click Snapshots: nav starts | `…/disks` (k1) | `…/disks` | k1: 143 |
143 |
| Nav completes: page changed → scroll to cached (none) | `…/snapshots`
(k2) | `…/snapshots` | k1: 143 | 0 |
| Back: nav starts | `…/snapshots` (k2) | `…/snapshots` | k1: 143, k2: 0
| 0 |
| Nav completes: page changed → scroll to cached | `…/disks` (k1) |
`…/disks` | k1: 143, k2: 0 | **143** |
#### Page → modal → page (open the New disk form, then dismiss it)
| Step | Location | Page path | Cache | Scroll |
| ------------------------------------------------------------- |
------------------ | --------- | ------------------------- | ------- |
| Scroll the disks page | `…/disks` (k1) | `…/disks` | | 143 |
| Click New disk: nav starts | `…/disks` (k1) | `…/disks` | k1: 143 |
143 |
| Nav completes: same page → leave scroll, record under new key |
`…/disks-new` (k2) | `…/disks` | k1: 143, k2: 143 | **143** |
| Dismiss: nav starts | `…/disks-new` (k2) | `…/disks` | k1: 143, k2:
143 | 143 |
| Nav completes: same page → leave scroll, record under new key |
`…/disks` (k3) | `…/disks` | k1: 143, k2: 143, k3: 143 | **143** |
#### Modal submit → new page (create a VPC, land on VPC detail page)
| Step | Location | Page path | Cache | Scroll |
| ----------------------------------------------------- |
-------------------- | --------------- | ---------------- | ------ |
| Modal open over scrolled VPCs page | `…/vpcs-new` (k2) | `…/vpcs` |
k1: 143, k2: 143 | 143 |
| Submit: nav starts | `…/vpcs-new` (k2) | `…/vpcs` | k1: 143, k2: 143 |
143 |
| Nav completes: page changed → scroll to cached (none) |
`…/vpcs/my-vpc` (k3) | `…/vpcs/my-vpc` | k1: 143, k2: 143 | **0** |
0 commit comments