Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(experimental scroll): use sessionStorage instead of history #20633

Merged
merged 6 commits into from Dec 31, 2020

Conversation

Timer
Copy link
Member

@Timer Timer commented Dec 31, 2020

This pull request adjusts our experimental scroll restoration behavior to use sessionStorage as opposed to History#replaceState to track scroll position.

In addition, it eliminates a scroll event listener and only captures when a pushState event happens (thereby leaving state that needs snapshotted).

These merely adjusts implementation detail, and is covered by existing tests:

test/integration/scroll-back-restoration/

Fixes #16690
Fixes #17073
Fixes #20486

@vercel vercel bot temporarily deployed to Preview December 31, 2020 06:25 Inactive
@vercel vercel bot temporarily deployed to Preview December 31, 2020 06:25 Inactive
@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@vercel vercel bot temporarily deployed to Preview December 31, 2020 07:19 Inactive
@ijjk
Copy link
Member

ijjk commented Dec 31, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
buildDuration 10.3s 10.5s ⚠️ +277ms
nodeModulesSize 83 MB 83 MB ⚠️ +2.61 kB
Page Load Tests Overall increase ✓
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
/ failed reqs 0 0
/ total time (seconds) 2.118 2.037 -0.08
/ avg req/sec 1180.37 1227 +46.63
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.3 1.255 -0.05
/error-in-render avg req/sec 1923.59 1991.31 +67.72
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
677f882d2ed8..6cec.js gzip 12.8 kB 12.9 kB ⚠️ +60 B
framework.HASH.js gzip 39 kB 39 kB
main-5b13c61..eaca.js gzip 6.59 kB 6.59 kB ⚠️ +5 B
webpack-7193..1446.js gzip 751 B 751 B
Overall change 59.1 kB 59.2 kB ⚠️ +65 B
Legacy Client Bundles (polyfills)
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
polyfills-67..b7d1.js gzip 31.2 kB 31.2 kB
Overall change 31.2 kB 31.2 kB
Client Pages
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_app-6220e08..9a40.js gzip 1.28 kB 1.28 kB
_error-4b0b5..2c91.js gzip 3.44 kB 3.44 kB
hooks-5f309a..7282.js gzip 887 B 887 B
index-57f580..c562.js gzip 227 B 227 B
link-1a1f628..eeb5.js gzip 1.61 kB 1.61 kB
routerDirect..bd82.js gzip 303 B 303 B
withRouter-2..e384.js gzip 302 B 302 B
Overall change 8.05 kB 8.05 kB
Client Build Manifests
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_buildManifest.js gzip 322 B 322 B
Overall change 322 B 322 B
Rendered Page Sizes
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
index.html gzip 617 B 616 B -1 B
link.html gzip 621 B 622 B ⚠️ +1 B
withRouter.html gzip 610 B 610 B
Overall change 1.85 kB 1.85 kB

Diffs

Diff for 677f882d2ed8..74301f1c8.js
@@ -1549,6 +1549,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           this.locales = void 0;
           this.defaultLocale = void 0;
           this.domainLocales = void 0;
+          this._idx = 0;
 
           this.onPopState = function(e) {
             var state = e.state;
@@ -1582,9 +1583,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               return;
             }
 
+            var forcedScroll;
             var url = state.url,
               as = state.as,
-              options = state.options;
+              options = state.options,
+              idx = state.idx;
+
+            if (false) {
+              var v;
+            }
+
+            _this._idx = idx;
 
             var _ref2 = (0, _parseRelativeUrl.parseRelativeUrl)(url),
               pathname = _ref2.pathname; // Make sure we don't re-render on initial load,
@@ -1610,7 +1619,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               Object.assign({}, options, {
                 shallow: options.shallow && _this._shallow,
                 locale: options.locale || _this.defaultLocale
-              })
+              }),
+              forcedScroll
             );
           }; // represents the current component key
 
@@ -1687,7 +1697,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             // otherwise fallback to browser's default handling
 
             if (false) {
-              var debouncedScrollSave, scrollDebounceTimeout;
             }
           }
         }
@@ -1721,6 +1730,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 arguments.length > 2 && arguments[2] !== undefined
                   ? arguments[2]
                   : {};
+
+              if (false) {
+              }
+
               var _prepareUrlAs = prepareUrlAs(this, url, as);
 
               url = _prepareUrlAs.url;
@@ -1756,7 +1769,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   method,
                   url,
                   as,
-                  options
+                  options,
+                  forcedScroll
                 ) {
                   var _this2 = this;
 
@@ -1947,7 +1961,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
                             this.changeState(method, url, as, options);
                             this.scrollToHash(cleanedAs);
-                            this.notify(this.components[this.route], false);
+                            this.notify(this.components[this.route], null);
                             Router.events.emit(
                               "hashChangeComplete",
                               as,
@@ -2242,7 +2256,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               query,
                               cleanedAs,
                               routeInfo,
-                              !!options.scroll
+                              forcedScroll ||
+                                (options.scroll
+                                  ? {
+                                      x: 0,
+                                      y: 0
+                                    }
+                                  : null)
                             )["catch"](function(e) {
                               if (e.cancelled) error = error || e;
                               else throw e;
@@ -2266,9 +2286,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             if (false) {
                             }
 
-                            if (false) {
-                            }
-
                             Router.events.emit(
                               "routeChangeComplete",
                               as,
@@ -2276,21 +2293,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             );
                             return _context.abrupt("return", true);
 
-                          case 116:
-                            _context.prev = 116;
+                          case 115:
+                            _context.prev = 115;
                             _context.t2 = _context["catch"](73);
 
                             if (!_context.t2.cancelled) {
-                              _context.next = 120;
+                              _context.next = 119;
                               break;
                             }
 
                             return _context.abrupt("return", false);
 
-                          case 120:
+                          case 119:
                             throw _context.t2;
 
-                          case 121:
+                          case 120:
                           case "end":
                             return _context.stop();
                         }
@@ -2300,14 +2317,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     this,
                     [
                       [35, 45],
-                      [73, 116],
+                      [73, 115],
                       [90, 96]
                     ]
                   );
                 })
               );
 
-              function change(_x, _x2, _x3, _x4) {
+              function change(_x, _x2, _x3, _x4, _x5) {
                 return _change.apply(this, arguments);
               }
 
@@ -2332,7 +2349,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     url: url,
                     as: as,
                     options: options,
-                    __N: true
+                    __N: true,
+                    idx: (this._idx =
+                      method !== "pushState" ? this._idx : this._idx + 1)
                   }, // Most browsers currently ignores this parameter, although they may use it in the future.
                   // Passing the empty string here should be safe against future changes to the method.
                   // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
@@ -2490,7 +2509,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9, _x10) {
+              function handleRouteInfoError(_x6, _x7, _x8, _x9, _x10, _x11) {
                 return _handleRouteInfoError.apply(this, arguments);
               }
 
@@ -2674,7 +2693,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function getRouteInfo(_x11, _x12, _x13, _x14, _x15) {
+              function getRouteInfo(_x12, _x13, _x14, _x15, _x16) {
                 return _getRouteInfo.apply(this, arguments);
               }
 
@@ -2911,7 +2930,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function prefetch(_x16) {
+              function prefetch(_x17) {
                 return _prefetch.apply(this, arguments);
               }
 
@@ -2976,7 +2995,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function fetchComponent(_x17) {
+              function fetchComponent(_x18) {
                 return _fetchComponent.apply(this, arguments);
               }
Diff for main-ced312f..15e5e1e30.js
@@ -1168,7 +1168,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
           }
 
           if (input.scroll) {
-            window.scrollTo(0, 0);
+            window.scrollTo(input.scroll.x, input.scroll.y);
           }
         }
Diff for index.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      href="/_next/static/chunks/main-71523b4f5915256752dc.js"
       as="script"
     />
     <link
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.75a51471efa19b7343fa.js"
       as="script"
     />
     <link
@@ -53,7 +53,7 @@
       src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
     ></script>
     <script
-      src="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      src="/_next/static/chunks/main-71523b4f5915256752dc.js"
       async=""
     ></script>
     <script
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.75a51471efa19b7343fa.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      href="/_next/static/chunks/main-71523b4f5915256752dc.js"
       as="script"
     />
     <link
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.75a51471efa19b7343fa.js"
       as="script"
     />
     <link
@@ -58,7 +58,7 @@
       src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
     ></script>
     <script
-      src="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      src="/_next/static/chunks/main-71523b4f5915256752dc.js"
       async=""
     ></script>
     <script
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.75a51471efa19b7343fa.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      href="/_next/static/chunks/main-71523b4f5915256752dc.js"
       as="script"
     />
     <link
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.75a51471efa19b7343fa.js"
       as="script"
     />
     <link
@@ -53,7 +53,7 @@
       src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
     ></script>
     <script
-      src="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      src="/_next/static/chunks/main-71523b4f5915256752dc.js"
       async=""
     ></script>
     <script
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3bda7895f2274301f1c8.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.75a51471efa19b7343fa.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
buildDuration 12.4s 12.7s ⚠️ +260ms
nodeModulesSize 83 MB 83 MB ⚠️ +2.61 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
677f882d2ed8..6cec.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-5b13c61..eaca.js gzip 6.59 kB N/A N/A
webpack-7193..1446.js gzip 751 B 751 B
677f882d2ed8..f51e.js gzip N/A 12.9 kB N/A
main-212f85f..f23b.js gzip N/A 6.59 kB N/A
Overall change 59.1 kB 59.2 kB ⚠️ +65 B
Legacy Client Bundles (polyfills)
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
polyfills-67..b7d1.js gzip 31.2 kB 31.2 kB
Overall change 31.2 kB 31.2 kB
Client Pages
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_app-6220e08..9a40.js gzip 1.28 kB 1.28 kB
_error-4b0b5..2c91.js gzip 3.44 kB 3.44 kB
hooks-5f309a..7282.js gzip 887 B 887 B
index-57f580..c562.js gzip 227 B 227 B
link-1a1f628..eeb5.js gzip 1.61 kB 1.61 kB
routerDirect..bd82.js gzip 303 B 303 B
withRouter-2..e384.js gzip 302 B 302 B
Overall change 8.05 kB 8.05 kB
Client Build Manifests
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_buildManifest.js gzip 322 B 322 B
Overall change 322 B 322 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB ⚠️ +265 B
routerDirect.js 1.05 MB 1.05 MB ⚠️ +265 B
withRouter.js 1.05 MB 1.05 MB ⚠️ +265 B
Overall change 5.17 MB 5.17 MB ⚠️ +795 B
Commit: 62c3517

@Timer Timer marked this pull request as ready for review December 31, 2020 07:37
@vercel vercel bot temporarily deployed to Preview December 31, 2020 15:48 Inactive
@ijjk
Copy link
Member

ijjk commented Dec 31, 2020

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
buildDuration 11.3s 11.3s ⚠️ +36ms
nodeModulesSize 83 MB 83 MB ⚠️ +2.61 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
/ failed reqs 0 0
/ total time (seconds) 2.304 2.277 -0.03
/ avg req/sec 1085.25 1097.9 +12.65
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.635 1.66 ⚠️ +0.02
/error-in-render avg req/sec 1528.68 1505.6 ⚠️ -23.08
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
677f882d2ed8..8a8f.js gzip 12.8 kB 12.9 kB ⚠️ +59 B
framework.HASH.js gzip 39 kB 39 kB
main-5b13c61..eaca.js gzip 6.59 kB 6.59 kB ⚠️ +5 B
webpack-7193..1446.js gzip 751 B 751 B
Overall change 59.1 kB 59.2 kB ⚠️ +64 B
Legacy Client Bundles (polyfills)
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
polyfills-67..b7d1.js gzip 31.2 kB 31.2 kB
Overall change 31.2 kB 31.2 kB
Client Pages
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_app-6220e08..9a40.js gzip 1.28 kB 1.28 kB
_error-4b0b5..2c91.js gzip 3.44 kB 3.44 kB
hooks-5f309a..7282.js gzip 887 B 887 B
index-57f580..c562.js gzip 227 B 227 B
link-b862cd7..dba8.js gzip 1.64 kB 1.64 kB
routerDirect..bd82.js gzip 303 B 303 B
withRouter-2..e384.js gzip 302 B 302 B
Overall change 8.08 kB 8.08 kB
Client Build Manifests
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
index.html gzip 616 B 616 B
link.html gzip 622 B 622 B
withRouter.html gzip 610 B 609 B -1 B
Overall change 1.85 kB 1.85 kB -1 B

Diffs

Diff for 677f882d2ed8..e16684765.js
@@ -1558,6 +1558,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
           this.locales = void 0;
           this.defaultLocale = void 0;
           this.domainLocales = void 0;
+          this._idx = 0;
 
           this.onPopState = function(e) {
             var state = e.state;
@@ -1591,9 +1592,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               return;
             }
 
+            var forcedScroll;
             var url = state.url,
               as = state.as,
-              options = state.options;
+              options = state.options,
+              idx = state.idx;
+
+            if (false) {
+              var v;
+            }
+
+            _this._idx = idx;
 
             var _ref2 = (0, _parseRelativeUrl.parseRelativeUrl)(url),
               pathname = _ref2.pathname; // Make sure we don't re-render on initial load,
@@ -1619,7 +1628,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
               Object.assign({}, options, {
                 shallow: options.shallow && _this._shallow,
                 locale: options.locale || _this.defaultLocale
-              })
+              }),
+              forcedScroll
             );
           }; // represents the current component key
 
@@ -1696,7 +1706,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
             // otherwise fallback to browser's default handling
 
             if (false) {
-              var debouncedScrollSave, scrollDebounceTimeout;
             }
           }
         }
@@ -1730,6 +1739,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 arguments.length > 2 && arguments[2] !== undefined
                   ? arguments[2]
                   : {};
+
+              if (false) {
+              }
+
               var _prepareUrlAs = prepareUrlAs(this, url, as);
 
               url = _prepareUrlAs.url;
@@ -1765,7 +1778,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                   method,
                   url,
                   as,
-                  options
+                  options,
+                  forcedScroll
                 ) {
                   var _this2 = this;
 
@@ -1956,7 +1970,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
 
                             this.changeState(method, url, as, options);
                             this.scrollToHash(cleanedAs);
-                            this.notify(this.components[this.route], false);
+                            this.notify(this.components[this.route], null);
                             Router.events.emit(
                               "hashChangeComplete",
                               as,
@@ -2251,7 +2265,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                               query,
                               cleanedAs,
                               routeInfo,
-                              !!options.scroll
+                              forcedScroll ||
+                                (options.scroll
+                                  ? {
+                                      x: 0,
+                                      y: 0
+                                    }
+                                  : null)
                             )["catch"](function(e) {
                               if (e.cancelled) error = error || e;
                               else throw e;
@@ -2275,9 +2295,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             if (false) {
                             }
 
-                            if (false) {
-                            }
-
                             Router.events.emit(
                               "routeChangeComplete",
                               as,
@@ -2285,21 +2302,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                             );
                             return _context.abrupt("return", true);
 
-                          case 116:
-                            _context.prev = 116;
+                          case 115:
+                            _context.prev = 115;
                             _context.t2 = _context["catch"](73);
 
                             if (!_context.t2.cancelled) {
-                              _context.next = 120;
+                              _context.next = 119;
                               break;
                             }
 
                             return _context.abrupt("return", false);
 
-                          case 120:
+                          case 119:
                             throw _context.t2;
 
-                          case 121:
+                          case 120:
                           case "end":
                             return _context.stop();
                         }
@@ -2309,14 +2326,14 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     this,
                     [
                       [35, 45],
-                      [73, 116],
+                      [73, 115],
                       [90, 96]
                     ]
                   );
                 })
               );
 
-              function change(_x, _x2, _x3, _x4) {
+              function change(_x, _x2, _x3, _x4, _x5) {
                 return _change.apply(this, arguments);
               }
 
@@ -2341,7 +2358,9 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                     url: url,
                     as: as,
                     options: options,
-                    __N: true
+                    __N: true,
+                    idx: (this._idx =
+                      method !== "pushState" ? this._idx : this._idx + 1)
                   }, // Most browsers currently ignores this parameter, although they may use it in the future.
                   // Passing the empty string here should be safe against future changes to the method.
                   // https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState
@@ -2499,7 +2518,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function handleRouteInfoError(_x5, _x6, _x7, _x8, _x9, _x10) {
+              function handleRouteInfoError(_x6, _x7, _x8, _x9, _x10, _x11) {
                 return _handleRouteInfoError.apply(this, arguments);
               }
 
@@ -2683,7 +2702,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function getRouteInfo(_x11, _x12, _x13, _x14, _x15) {
+              function getRouteInfo(_x12, _x13, _x14, _x15, _x16) {
                 return _getRouteInfo.apply(this, arguments);
               }
 
@@ -2920,7 +2939,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function prefetch(_x16) {
+              function prefetch(_x17) {
                 return _prefetch.apply(this, arguments);
               }
 
@@ -2985,7 +3004,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
                 })
               );
 
-              function fetchComponent(_x17) {
+              function fetchComponent(_x18) {
                 return _fetchComponent.apply(this, arguments);
               }
Diff for main-ced312f..15e5e1e30.js
@@ -1168,7 +1168,7 @@ _N_E = (window["webpackJsonp_N_E"] = window["webpackJsonp_N_E"] || []).push([
           }
 
           if (input.scroll) {
-            window.scrollTo(0, 0);
+            window.scrollTo(input.scroll.x, input.scroll.y);
           }
         }
Diff for index.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      href="/_next/static/chunks/main-71523b4f5915256752dc.js"
       as="script"
     />
     <link
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
       as="script"
     />
     <link
@@ -53,7 +53,7 @@
       src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
     ></script>
     <script
-      src="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      src="/_next/static/chunks/main-71523b4f5915256752dc.js"
       async=""
     ></script>
     <script
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
       async=""
     ></script>
     <script
Diff for link.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      href="/_next/static/chunks/main-71523b4f5915256752dc.js"
       as="script"
     />
     <link
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
       as="script"
     />
     <link
@@ -58,7 +58,7 @@
       src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
     ></script>
     <script
-      src="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      src="/_next/static/chunks/main-71523b4f5915256752dc.js"
       async=""
     ></script>
     <script
@@ -70,7 +70,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
       async=""
     ></script>
     <script
Diff for withRouter.html
@@ -7,7 +7,7 @@
     <noscript data-n-css=""></noscript>
     <link
       rel="preload"
-      href="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      href="/_next/static/chunks/main-71523b4f5915256752dc.js"
       as="script"
     />
     <link
@@ -22,7 +22,7 @@
     />
     <link
       rel="preload"
-      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
+      href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
       as="script"
     />
     <link
@@ -53,7 +53,7 @@
       src="/_next/static/chunks/polyfills-ae47a1f95297af5f55f8.js"
     ></script>
     <script
-      src="/_next/static/chunks/main-ced312fb15315e5e1e30.js"
+      src="/_next/static/chunks/main-71523b4f5915256752dc.js"
       async=""
     ></script>
     <script
@@ -65,7 +65,7 @@
       async=""
     ></script>
     <script
-      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.bab86a96808e16684765.js"
+      src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.2d9f36cd3bbf7195fca6.js"
       async=""
     ></script>
     <script

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
buildDuration 13.2s 13.3s ⚠️ +141ms
nodeModulesSize 83 MB 83 MB ⚠️ +2.61 kB
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
677f882d2ed8..8a8f.js gzip 12.8 kB N/A N/A
framework.HASH.js gzip 39 kB 39 kB
main-5b13c61..eaca.js gzip 6.59 kB N/A N/A
webpack-7193..1446.js gzip 751 B 751 B
677f882d2ed8..381c.js gzip N/A 12.9 kB N/A
main-212f85f..f23b.js gzip N/A 6.59 kB N/A
Overall change 59.1 kB 59.2 kB ⚠️ +64 B
Legacy Client Bundles (polyfills)
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
polyfills-67..b7d1.js gzip 31.2 kB 31.2 kB
Overall change 31.2 kB 31.2 kB
Client Pages
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_app-6220e08..9a40.js gzip 1.28 kB 1.28 kB
_error-4b0b5..2c91.js gzip 3.44 kB 3.44 kB
hooks-5f309a..7282.js gzip 887 B 887 B
index-57f580..c562.js gzip 227 B 227 B
link-b862cd7..dba8.js gzip 1.64 kB 1.64 kB
routerDirect..bd82.js gzip 303 B 303 B
withRouter-2..e384.js gzip 302 B 302 B
Overall change 8.08 kB 8.08 kB
Client Build Manifests
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_buildManifest.js gzip 321 B 321 B
Overall change 321 B 321 B
Serverless bundles Overall increase ⚠️
vercel/next.js canary Timer/next.js hotfix/experimental-scroll Change
_error.js 1 MB 1 MB
404.html 2.67 kB 2.67 kB
hooks.html 1.92 kB 1.92 kB
index.js 1 MB 1 MB
link.js 1.06 MB 1.06 MB ⚠️ +265 B
routerDirect.js 1.05 MB 1.05 MB ⚠️ +265 B
withRouter.js 1.05 MB 1.05 MB ⚠️ +265 B
Overall change 5.17 MB 5.17 MB ⚠️ +795 B
Commit: 779ed5a

@kodiakhq kodiakhq bot merged commit dbe1e62 into vercel:canary Dec 31, 2020
@ijjk ijjk deleted the hotfix/experimental-scroll branch December 31, 2020 16:08
@yayvery
Copy link

yayvery commented Jan 4, 2021

This update broke store restoration entirely for me. Now scrolls to the top every time.

@Timer
Copy link
Member Author

Timer commented Jan 4, 2021

Please PR a failing test case so we can get it fixed.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants