rsnext/test/e2e/app-dir/navigation/app
Zack Tanner a578cc8192
fix inconsistent scroll restoration behavior (#59366)
### What?
While scrolled on a page, and when following a link to a new page and
clicking the browser back button or using `router.back()`, the scroll
position would sometimes restore scroll to the incorrect spot (in the
case of the test added in this PR, it'd scroll you back to the top of
the list)

### Why?
The refactor in #56497 changed the way router actions are processed:
specifically, all actions were assumed to be async, even if they could
be handled synchronously. For most actions this is fine, as most are
currently async. However, `ACTION_RESTORE` (triggered when the
`popstate` event occurs) isn't async, and introducing a small amount of
delay in the handling of this action can cause the browser to not
properly restore the scroll position

### How?
This special-cases `ACTION_RESTORE` to synchronously process the action
and call `setState` when it's received, rather than creating a promise.
To consistently reproduce this behavior, I added an option to our
browser interface that'll allow us to programmatically trigger a CPU
slowdown.

h/t to @alvarlagerlof for isolating the offending commit and sharing a
minimal reproduction.

Closes NEXT-1819
Likely addresses #58899 but the reproduction was too complex to verify.
2023-12-07 11:17:15 -08:00
..
assertion Export RedirectType from next/navigation (#54729) 2023-08-29 11:05:44 -07:00
external-push/[storageKey] app router: Fix infinite redirect loop in MPA navigation (#49058) 2023-05-03 11:04:53 +02:00
hash App Router: fix relative query/hash handling in next/link and router push/replace (#49521) 2023-05-28 10:29:00 -07:00
hash-changes Support scroll: false for Link component for app router (#51869) 2023-07-04 10:25:25 +02:00
hash-link-back-to-same-page Fix going back to page after applying hash link (#50006) 2023-05-18 16:33:58 -07:00
hash-link-to-pages-router fix(next/client): keep hash when navigating from app to pages router (#56223) 2023-10-02 14:43:04 -07:00
hash-with-scroll-offset fix: app router hash scrolling should respect scroll-padding (#51268) 2023-06-13 20:50:51 -07:00
mpa-nav-test fix: ensure mpa navigation render side effects are only fired once (#55032) 2023-09-07 20:53:07 +00:00
nested-navigation fix infinite navigate events when Promise is proxied (#54394) 2023-08-24 16:22:48 +00:00
nested-relative-query-and-hash App Router: fix relative query/hash handling in next/link and router push/replace (#49521) 2023-05-28 10:29:00 -07:00
not-found Failing tests for 404 back/forward (#50047) 2023-05-22 17:04:36 +02:00
redirect Export RedirectType from next/navigation (#54729) 2023-08-29 11:05:44 -07:00
redirect-dest
router Fix client chunk loading encoding for dynamic route (#57960) 2023-11-02 23:09:25 +00:00
scroll-restoration fix inconsistent scroll restoration behavior (#59366) 2023-12-07 11:17:15 -08:00
search-params fix: Don't reset shallow URL updates on prefetch (#58297) 2023-11-14 19:29:18 +00:00
layout.js Add test for next-found and redirect for metadata (#46248) 2023-02-22 18:54:14 +01:00
page.js