38bd1a024c
This updates the scroll position saving to occur as the scroll position changes instead of trying to do it when the navigation is changing since the `popState` event doesn't allow us to update the leaving history state once the `popState` has occurred. The order of events that was previously attempted to save scroll position on a `popState` event (back/forward navigation) 1. history.state is already updated with state from `popState` 2. we replace state with the currently rendered page adding scroll info 3. we replace state again with the `popState` event state overriding scroll info Using this approach the above event order is no longer in conflict since we don't attempt to populate the state with scroll position while it's leaving the state and instead do it while it is still the active state in history This approach resembles existing solutions: https://www.npmjs.com/package/scroll-behavior https://twitter.com/ryanflorence/status/1029121580855488512 Fixes: https://github.com/vercel/next.js/issues/13990 Fixes: #12530 x-ref: https://github.com/vercel/next.js/pull/14075 |
||
---|---|---|
.. | ||
pages | ||
test | ||
next.config.js |