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 shallow routing scroll #21437
Fix shallow routing scroll #21437
Conversation
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
buildDuration | 10.2s | 10.2s | |
nodeModulesSize | 73.3 MB | 73.3 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.02 | 2.053 | |
/ avg req/sec | 1237.77 | 1217.93 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.221 | 1.254 | |
/error-in-render avg req/sec | 2047.57 | 1994.38 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
677f882d2ed8..bb74.js gzip | 13.1 kB | 13.1 kB | |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-HASH.js gzip | 6.63 kB | 6.63 kB | ✓ |
webpack-HASH.js gzip | 751 B | 751 B | ✓ |
Overall change | 59.4 kB | 59.4 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.3 kB | 31.3 kB | ✓ |
Overall change | 31.3 kB | 31.3 kB | ✓ |
Client Pages
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_app-2a09aa2..4a98.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-8b758..aef6.js gzip | 3.46 kB | 3.46 kB | ✓ |
hooks-c71ae4..70cd.js gzip | 887 B | 887 B | ✓ |
index-bbee2f..528b.js gzip | 227 B | 227 B | ✓ |
link-7faf09b..eba4.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..bf84.js gzip | 303 B | 303 B | ✓ |
withRouter-a..5826.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.09 kB | 8.09 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
index.html gzip | 613 B | 614 B | |
link.html gzip | 620 B | 620 B | ✓ |
withRouter.html gzip | 608 B | 608 B | ✓ |
Overall change | 1.84 kB | 1.84 kB |
Diffs
Diff for 677f882d2ed8..ac9dfbed6.js
@@ -1860,7 +1860,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
newUrl,
newAs,
notFoundRoute,
- appComp;
+ appComp,
+ isValidShallowRoute;
return _regeneratorRuntime.wrap(
function _callee$(_context) {
@@ -2324,9 +2325,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.changeState(method, url, as, options);
if (false) {
- }
+ } // shallow routing is only allowed for same page URL changes.
- _context.next = 113;
+ isValidShallowRoute =
+ options.shallow && this.route === route;
+ _context.next = 114;
return this.set(
route,
pathname,
@@ -2334,20 +2337,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
cleanedAs,
routeInfo,
forcedScroll ||
- (options.scroll
- ? {
+ (isValidShallowRoute || !options.scroll
+ ? null
+ : {
x: 0,
y: 0
- }
- : null)
+ })
)["catch"](function(e) {
if (e.cancelled) error = error || e;
else throw e;
});
- case 113:
+ case 114:
if (!error) {
- _context.next = 116;
+ _context.next = 117;
break;
}
@@ -2359,7 +2362,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
throw error;
- case 116:
+ case 117:
if (false) {
}
@@ -2370,21 +2373,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 121:
- _context.prev = 121;
+ case 122:
+ _context.prev = 122;
_context.t2 = _context["catch"](79);
if (!_context.t2.cancelled) {
- _context.next = 125;
+ _context.next = 126;
break;
}
return _context.abrupt("return", false);
- case 125:
+ case 126:
throw _context.t2;
- case 126:
+ case 127:
case "end":
return _context.stop();
}
@@ -2394,7 +2397,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this,
[
[36, 46],
- [79, 121],
+ [79, 122],
[96, 102]
]
);
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
async=""
></script>
<script
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
as="script"
/>
<link
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
async=""
></script>
<script
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
async=""
></script>
<script
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
buildDuration | 12s | 12.1s | |
nodeModulesSize | 73.3 MB | 73.3 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
677f882d2ed8..bb74.js gzip | 13.1 kB | N/A | N/A |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-HASH.js gzip | 6.63 kB | 6.63 kB | ✓ |
webpack-HASH.js gzip | 751 B | 751 B | ✓ |
677f882d2ed8..38ed.js gzip | N/A | 13.1 kB | N/A |
Overall change | 59.4 kB | 59.4 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.3 kB | 31.3 kB | ✓ |
Overall change | 31.3 kB | 31.3 kB | ✓ |
Client Pages
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_app-2a09aa2..4a98.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-8b758..aef6.js gzip | 3.46 kB | 3.46 kB | ✓ |
hooks-c71ae4..70cd.js gzip | 887 B | 887 B | ✓ |
index-bbee2f..528b.js gzip | 227 B | 227 B | ✓ |
link-7faf09b..eba4.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..bf84.js gzip | 303 B | 303 B | ✓ |
withRouter-a..5826.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.09 kB | 8.09 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-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 | |
routerDirect.js | 1.05 MB | 1.05 MB | |
withRouter.js | 1.05 MB | 1.05 MB | |
Overall change | 5.19 MB | 5.19 MB |
Webpack 5 Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
buildDuration | 12.4s | 12.3s | -145ms |
nodeModulesSize | 73.3 MB | 73.3 MB |
Page Load Tests Overall decrease ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.014 | 2.025 | |
/ avg req/sec | 1241.02 | 1234.67 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.221 | 1.275 | |
/error-in-render avg req/sec | 2047.68 | 1960.32 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
597-168f5a87..2380.js gzip | 13 kB | 13 kB | |
framework.HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 6.58 kB | 6.58 kB | ✓ |
webpack-HASH.js gzip | 954 B | 954 B | ✓ |
Overall change | 59.8 kB | 59.8 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_app-a5b2e84..33cf.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error-6f1f9..5577.js gzip | 3.38 kB | 3.38 kB | ✓ |
hooks-725de8..0a15.js gzip | 904 B | 904 B | ✓ |
index-939503..6e1c.js gzip | 232 B | 232 B | ✓ |
link-e0cc871..fdbb.js gzip | 1.63 kB | 1.63 kB | ✓ |
routerDirect..9360.js gzip | 308 B | 308 B | ✓ |
withRouter-6..44ec.js gzip | 304 B | 304 B | ✓ |
Overall change | 8.02 kB | 8.02 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_buildManifest.js gzip | 299 B | 299 B | ✓ |
Overall change | 299 B | 299 B | ✓ |
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
index.html gzip | 588 B | 588 B | ✓ |
link.html gzip | 593 B | 593 B | ✓ |
withRouter.html gzip | 583 B | 581 B | -2 B |
Overall change | 1.76 kB | 1.76 kB | -2 B |
Diffs
Diff for 677f882d2ed8..d6246bb74.js
@@ -1066,7 +1066,8 @@
K,
tt,
et,
- rt;
+ rt,
+ nt;
return n.wrap(
function(e) {
for (;;)
@@ -1312,44 +1313,45 @@
return (
t.events.emit("beforeHistoryChange", a, g),
this.changeState(r, o, a, i),
- (e.next = 113),
+ (nt = i.shallow && this.route === D),
+ (e.next = 114),
this.set(
D,
C,
I,
w,
V,
- u || (i.scroll ? { x: 0, y: 0 } : null)
+ u || (nt || !i.scroll ? null : { x: 0, y: 0 })
).catch(function(t) {
if (!t.cancelled) throw t;
z = z || t;
})
);
- case 113:
+ case 114:
if (!z) {
- e.next = 116;
+ e.next = 117;
break;
}
throw (t.events.emit("routeChangeError", z, w, g),
z);
- case 116:
+ case 117:
return (
t.events.emit("routeChangeComplete", a, g),
e.abrupt("return", !0)
);
- case 121:
+ case 122:
if (
- ((e.prev = 121),
+ ((e.prev = 122),
(e.t2 = e.catch(79)),
!e.t2.cancelled)
) {
- e.next = 125;
+ e.next = 126;
break;
}
return e.abrupt("return", !1);
- case 125:
- throw e.t2;
case 126:
+ throw e.t2;
+ case 127:
case "end":
return e.stop();
}
@@ -1358,7 +1360,7 @@
this,
[
[36, 46],
- [79, 121],
+ [79, 122],
[96, 102]
]
);
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
as="script"
/>
<link
@@ -43,7 +43,7 @@
"props": { "pageProps": {} },
"page": "/",
"query": {},
- "buildId": "51ENqzeG_ld23MHGjh6-z",
+ "buildId": "CtBNshUp_bqNKT_YXh9ON",
"isFallback": false,
"gip": true
}
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
async=""
></script>
<script
@@ -77,11 +77,11 @@
async=""
></script>
<script
- src="/_next/static/51ENqzeG_ld23MHGjh6-z/_buildManifest.js"
+ src="/_next/static/CtBNshUp_bqNKT_YXh9ON/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/51ENqzeG_ld23MHGjh6-z/_ssgManifest.js"
+ src="/_next/static/CtBNshUp_bqNKT_YXh9ON/_ssgManifest.js"
async=""
></script>
</body>
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
as="script"
/>
<link
@@ -48,7 +48,7 @@
"props": { "pageProps": {} },
"page": "/link",
"query": {},
- "buildId": "51ENqzeG_ld23MHGjh6-z",
+ "buildId": "CtBNshUp_bqNKT_YXh9ON",
"isFallback": false,
"gip": true
}
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
async=""
></script>
<script
@@ -82,11 +82,11 @@
async=""
></script>
<script
- src="/_next/static/51ENqzeG_ld23MHGjh6-z/_buildManifest.js"
+ src="/_next/static/CtBNshUp_bqNKT_YXh9ON/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/51ENqzeG_ld23MHGjh6-z/_ssgManifest.js"
+ src="/_next/static/CtBNshUp_bqNKT_YXh9ON/_ssgManifest.js"
async=""
></script>
</body>
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
as="script"
/>
<link
@@ -43,7 +43,7 @@
"props": { "pageProps": {} },
"page": "/withRouter",
"query": {},
- "buildId": "51ENqzeG_ld23MHGjh6-z",
+ "buildId": "CtBNshUp_bqNKT_YXh9ON",
"isFallback": false,
"gip": true
}
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
async=""
></script>
<script
@@ -77,11 +77,11 @@
async=""
></script>
<script
- src="/_next/static/51ENqzeG_ld23MHGjh6-z/_buildManifest.js"
+ src="/_next/static/CtBNshUp_bqNKT_YXh9ON/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/51ENqzeG_ld23MHGjh6-z/_ssgManifest.js"
+ src="/_next/static/CtBNshUp_bqNKT_YXh9ON/_ssgManifest.js"
async=""
></script>
</body>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
buildDuration | 9s | 8.9s | -37ms |
nodeModulesSize | 73.3 MB | 73.3 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.748 | 1.767 | |
/ avg req/sec | 1430.11 | 1414.83 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.104 | 1.092 | -0.01 |
/error-in-render avg req/sec | 2263.5 | 2288.83 | +25.33 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
677f882d2ed8..bb74.js gzip | 13.1 kB | 13.1 kB | |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-HASH.js gzip | 6.63 kB | 6.63 kB | ✓ |
webpack-HASH.js gzip | 751 B | 751 B | ✓ |
Overall change | 59.4 kB | 59.4 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.3 kB | 31.3 kB | ✓ |
Overall change | 31.3 kB | 31.3 kB | ✓ |
Client Pages
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_app-2a09aa2..4a98.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-8b758..aef6.js gzip | 3.46 kB | 3.46 kB | ✓ |
hooks-c71ae4..70cd.js gzip | 887 B | 887 B | ✓ |
index-bbee2f..528b.js gzip | 227 B | 227 B | ✓ |
link-7faf09b..eba4.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..bf84.js gzip | 303 B | 303 B | ✓ |
withRouter-a..5826.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.09 kB | 8.09 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
index.html gzip | 613 B | 614 B | |
link.html gzip | 620 B | 620 B | ✓ |
withRouter.html gzip | 608 B | 608 B | ✓ |
Overall change | 1.84 kB | 1.84 kB |
Diffs
Diff for 677f882d2ed8..ac9dfbed6.js
@@ -1860,7 +1860,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
newUrl,
newAs,
notFoundRoute,
- appComp;
+ appComp,
+ isValidShallowRoute;
return _regeneratorRuntime.wrap(
function _callee$(_context) {
@@ -2324,9 +2325,11 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this.changeState(method, url, as, options);
if (false) {
- }
+ } // shallow routing is only allowed for same page URL changes.
- _context.next = 113;
+ isValidShallowRoute =
+ options.shallow && this.route === route;
+ _context.next = 114;
return this.set(
route,
pathname,
@@ -2334,20 +2337,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
cleanedAs,
routeInfo,
forcedScroll ||
- (options.scroll
- ? {
+ (isValidShallowRoute || !options.scroll
+ ? null
+ : {
x: 0,
y: 0
- }
- : null)
+ })
)["catch"](function(e) {
if (e.cancelled) error = error || e;
else throw e;
});
- case 113:
+ case 114:
if (!error) {
- _context.next = 116;
+ _context.next = 117;
break;
}
@@ -2359,7 +2362,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
throw error;
- case 116:
+ case 117:
if (false) {
}
@@ -2370,21 +2373,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 121:
- _context.prev = 121;
+ case 122:
+ _context.prev = 122;
_context.t2 = _context["catch"](79);
if (!_context.t2.cancelled) {
- _context.next = 125;
+ _context.next = 126;
break;
}
return _context.abrupt("return", false);
- case 125:
+ case 126:
throw _context.t2;
- case 126:
+ case 127:
case "end":
return _context.stop();
}
@@ -2394,7 +2397,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this,
[
[36, 46],
- [79, 121],
+ [79, 122],
[96, 102]
]
);
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
async=""
></script>
<script
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
as="script"
/>
<link
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
async=""
></script>
<script
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.8750478fa37ac9dfbed6.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
async=""
></script>
<script
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
buildDuration | 10.7s | 10.7s | |
nodeModulesSize | 73.3 MB | 73.3 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
677f882d2ed8..bb74.js gzip | 13.1 kB | N/A | N/A |
framework.HASH.js gzip | 39 kB | 39 kB | ✓ |
main-HASH.js gzip | 6.63 kB | 6.63 kB | ✓ |
webpack-HASH.js gzip | 751 B | 751 B | ✓ |
677f882d2ed8..38ed.js gzip | N/A | 13.1 kB | N/A |
Overall change | 59.4 kB | 59.4 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.3 kB | 31.3 kB | ✓ |
Overall change | 31.3 kB | 31.3 kB | ✓ |
Client Pages
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_app-2a09aa2..4a98.js gzip | 1.28 kB | 1.28 kB | ✓ |
_error-8b758..aef6.js gzip | 3.46 kB | 3.46 kB | ✓ |
hooks-c71ae4..70cd.js gzip | 887 B | 887 B | ✓ |
index-bbee2f..528b.js gzip | 227 B | 227 B | ✓ |
link-7faf09b..eba4.js gzip | 1.64 kB | 1.64 kB | ✓ |
routerDirect..bf84.js gzip | 303 B | 303 B | ✓ |
withRouter-a..5826.js gzip | 302 B | 302 B | ✓ |
Overall change | 8.09 kB | 8.09 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-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 | |
routerDirect.js | 1.05 MB | 1.05 MB | |
withRouter.js | 1.05 MB | 1.05 MB | |
Overall change | 5.19 MB | 5.19 MB |
Webpack 5 Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
buildDuration | 10.8s | 10.7s | -78ms |
nodeModulesSize | 73.3 MB | 73.3 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 1.771 | 1.797 | |
/ avg req/sec | 1411.82 | 1390.92 | |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.142 | 1.084 | -0.06 |
/error-in-render avg req/sec | 2189.16 | 2305.99 | +116.83 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
597-168f5a87..2380.js gzip | 13 kB | 13 kB | |
framework.HASH.js gzip | 39.3 kB | 39.3 kB | ✓ |
main-HASH.js gzip | 6.58 kB | 6.58 kB | ✓ |
webpack-HASH.js gzip | 954 B | 954 B | ✓ |
Overall change | 59.8 kB | 59.8 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31.1 kB | 31.1 kB | ✓ |
Overall change | 31.1 kB | 31.1 kB | ✓ |
Client Pages
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_app-a5b2e84..33cf.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error-6f1f9..5577.js gzip | 3.38 kB | 3.38 kB | ✓ |
hooks-725de8..0a15.js gzip | 904 B | 904 B | ✓ |
index-939503..6e1c.js gzip | 232 B | 232 B | ✓ |
link-e0cc871..fdbb.js gzip | 1.63 kB | 1.63 kB | ✓ |
routerDirect..9360.js gzip | 308 B | 308 B | ✓ |
withRouter-6..44ec.js gzip | 304 B | 304 B | ✓ |
Overall change | 8.02 kB | 8.02 kB | ✓ |
Client Build Manifests
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
_buildManifest.js gzip | 299 B | 299 B | ✓ |
Overall change | 299 B | 299 B | ✓ |
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary | kaykdm/next.js fix/shallow-routing-scroll | Change | |
---|---|---|---|
index.html gzip | 588 B | 588 B | ✓ |
link.html gzip | 593 B | 593 B | ✓ |
withRouter.html gzip | 583 B | 581 B | -2 B |
Overall change | 1.76 kB | 1.76 kB | -2 B |
Diffs
Diff for 677f882d2ed8..d6246bb74.js
@@ -1066,7 +1066,8 @@
K,
tt,
et,
- rt;
+ rt,
+ nt;
return n.wrap(
function(e) {
for (;;)
@@ -1312,44 +1313,45 @@
return (
t.events.emit("beforeHistoryChange", a, g),
this.changeState(r, o, a, i),
- (e.next = 113),
+ (nt = i.shallow && this.route === D),
+ (e.next = 114),
this.set(
D,
C,
I,
w,
V,
- u || (i.scroll ? { x: 0, y: 0 } : null)
+ u || (nt || !i.scroll ? null : { x: 0, y: 0 })
).catch(function(t) {
if (!t.cancelled) throw t;
z = z || t;
})
);
- case 113:
+ case 114:
if (!z) {
- e.next = 116;
+ e.next = 117;
break;
}
throw (t.events.emit("routeChangeError", z, w, g),
z);
- case 116:
+ case 117:
return (
t.events.emit("routeChangeComplete", a, g),
e.abrupt("return", !0)
);
- case 121:
+ case 122:
if (
- ((e.prev = 121),
+ ((e.prev = 122),
(e.t2 = e.catch(79)),
!e.t2.cancelled)
) {
- e.next = 125;
+ e.next = 126;
break;
}
return e.abrupt("return", !1);
- case 125:
- throw e.t2;
case 126:
+ throw e.t2;
+ case 127:
case "end":
return e.stop();
}
@@ -1358,7 +1360,7 @@
this,
[
[36, 46],
- [79, 121],
+ [79, 122],
[96, 102]
]
);
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
as="script"
/>
<link
@@ -43,7 +43,7 @@
"props": { "pageProps": {} },
"page": "/",
"query": {},
- "buildId": "XdTPl6kxwTfZdjEZvxcKl",
+ "buildId": "Mka8AtlXjf6KboPyF_uUB",
"isFallback": false,
"gip": true
}
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
async=""
></script>
<script
@@ -77,11 +77,11 @@
async=""
></script>
<script
- src="/_next/static/XdTPl6kxwTfZdjEZvxcKl/_buildManifest.js"
+ src="/_next/static/Mka8AtlXjf6KboPyF_uUB/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/XdTPl6kxwTfZdjEZvxcKl/_ssgManifest.js"
+ src="/_next/static/Mka8AtlXjf6KboPyF_uUB/_ssgManifest.js"
async=""
></script>
</body>
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
as="script"
/>
<link
@@ -48,7 +48,7 @@
"props": { "pageProps": {} },
"page": "/link",
"query": {},
- "buildId": "XdTPl6kxwTfZdjEZvxcKl",
+ "buildId": "Mka8AtlXjf6KboPyF_uUB",
"isFallback": false,
"gip": true
}
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
async=""
></script>
<script
@@ -82,11 +82,11 @@
async=""
></script>
<script
- src="/_next/static/XdTPl6kxwTfZdjEZvxcKl/_buildManifest.js"
+ src="/_next/static/Mka8AtlXjf6KboPyF_uUB/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/XdTPl6kxwTfZdjEZvxcKl/_ssgManifest.js"
+ src="/_next/static/Mka8AtlXjf6KboPyF_uUB/_ssgManifest.js"
async=""
></script>
</body>
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
as="script"
/>
<link
@@ -43,7 +43,7 @@
"props": { "pageProps": {} },
"page": "/withRouter",
"query": {},
- "buildId": "XdTPl6kxwTfZdjEZvxcKl",
+ "buildId": "Mka8AtlXjf6KboPyF_uUB",
"isFallback": false,
"gip": true
}
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.203a9b065a4d6246bb74.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
async=""
></script>
<script
@@ -77,11 +77,11 @@
async=""
></script>
<script
- src="/_next/static/XdTPl6kxwTfZdjEZvxcKl/_buildManifest.js"
+ src="/_next/static/Mka8AtlXjf6KboPyF_uUB/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/XdTPl6kxwTfZdjEZvxcKl/_ssgManifest.js"
+ src="/_next/static/Mka8AtlXjf6KboPyF_uUB/_ssgManifest.js"
async=""
></script>
</body>
This PR disabled totally the option to scroll to the top on shallow rendering. There is an option ( |
May I ask why this change made specifically for shallow routing? As @luismramirezr mentioned, there is an option to explicitly disable the scroll. Why is that ignored for shallow routing? If this change remains, I would like to suggest that, at minimum, an explicit |
This ensures that Next.js will not scroll to the top of the page in shallow routing.
Fixes: #21386
Fixes: #21366