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
Allow scroll-to-top with shallow routing #21630
Conversation
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
buildDuration | 10.8s | 10.7s | -69ms |
nodeModulesSize | 75 MB | 75 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.344 | 2.223 | -0.12 |
/ avg req/sec | 1066.44 | 1124.53 | +58.09 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.53 | 1.58 | |
/error-in-render avg req/sec | 1633.53 | 1582.08 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
677f882d2ed8..38ed.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.5 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
index.html gzip | 614 B | 613 B | -1 B |
link.html gzip | 620 B | 619 B | -1 B |
withRouter.html gzip | 607 B | 607 B | ✓ |
Overall change | 1.84 kB | 1.84 kB | -2 B |
Diffs
Diff for 677f882d2ed8..dde534236.js
@@ -1861,7 +1861,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
newAs,
notFoundRoute,
appComp,
- isValidShallowRoute;
+ isValidShallowRoute,
+ resetScroll;
return _regeneratorRuntime.wrap(
function _callee$(_context) {
@@ -1888,6 +1889,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
options.scroll = !!((_options$scroll =
options.scroll) != null
? _options$scroll
+ : options.shallow
+ ? false
: true);
localeChange = options.locale !== this.locale;
@@ -2329,7 +2332,13 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
isValidShallowRoute =
options.shallow && this.route === route;
- _context.next = 114;
+ resetScroll = !options.scroll
+ ? null
+ : {
+ x: 0,
+ y: 0
+ };
+ _context.next = 115;
return this.set(
route,
pathname,
@@ -2337,20 +2346,17 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
cleanedAs,
routeInfo,
forcedScroll ||
- (isValidShallowRoute || !options.scroll
- ? null
- : {
- x: 0,
- y: 0
- })
+ (isValidShallowRoute
+ ? resetScroll
+ : false || resetScroll)
)["catch"](function(e) {
if (e.cancelled) error = error || e;
else throw e;
});
- case 114:
+ case 115:
if (!error) {
- _context.next = 117;
+ _context.next = 118;
break;
}
@@ -2362,7 +2368,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
throw error;
- case 117:
+ case 118:
if (false) {
}
@@ -2373,21 +2379,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 122:
- _context.prev = 122;
+ case 123:
+ _context.prev = 123;
_context.t2 = _context["catch"](79);
if (!_context.t2.cancelled) {
- _context.next = 126;
+ _context.next = 127;
break;
}
return _context.abrupt("return", false);
- case 126:
+ case 127:
throw _context.t2;
- case 127:
+ case 128:
case "end":
return _context.stop();
}
@@ -2397,7 +2403,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this,
[
[36, 46],
- [79, 122],
+ [79, 123],
[96, 102]
]
);
@@ -2785,6 +2791,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
key: "set",
value: function set(route, pathname, query, as, data, resetScroll) {
this.isFallback = false;
+ console.log({
+ route: route,
+ resetScroll: resetScroll
+ });
this.route = route;
this.pathname = pathname;
this.query = query;
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3b037616b14034013ab2.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3b037616b14034013ab2.js"
async=""
></script>
<script
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3b037616b14034013ab2.js"
as="script"
/>
<link
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3b037616b14034013ab2.js"
async=""
></script>
<script
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3b037616b14034013ab2.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d59cca9b248dde534236.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.3b037616b14034013ab2.js"
async=""
></script>
<script
Serverless Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
buildDuration | 12.8s | 12.8s | -23ms |
nodeModulesSize | 75 MB | 75 MB |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
677f882d2ed8..38ed.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..3a13.js gzip | N/A | 13.1 kB | N/A |
Overall change | 59.4 kB | 59.5 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles Overall increase ⚠️
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | 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.06 MB | |
withRouter.js | 1.05 MB | 1.06 MB | |
Overall change | 5.19 MB | 5.19 MB |
Webpack 5 Mode (Increase detected ⚠️ )
General Overall increase ⚠️
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
buildDuration | 13.6s | 13.3s | -317ms |
nodeModulesSize | 75 MB | 75 MB |
Page Load Tests Overall increase ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.305 | 2.246 | -0.06 |
/ avg req/sec | 1084.81 | 1112.91 | +28.1 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.596 | 1.599 | 0 |
/error-in-render avg req/sec | 1566.17 | 1563.36 |
Client Bundles (main, webpack, commons) Overall increase ⚠️
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
597-7c719119..27b6.js gzip | 13 kB | 13.1 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.9 kB |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
_app-6e0a903..b885.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error-7a100..a392.js gzip | 3.38 kB | 3.38 kB | ✓ |
hooks-f7e199..11b9.js gzip | 904 B | 904 B | ✓ |
index-3dc22c..ffbb.js gzip | 232 B | 232 B | ✓ |
link-c010d28..b60a.js gzip | 1.63 kB | 1.63 kB | ✓ |
routerDirect..323a.js gzip | 308 B | 308 B | ✓ |
withRouter-a..2ef8.js gzip | 304 B | 304 B | ✓ |
Overall change | 8.02 kB | 8.02 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
_buildManifest.js gzip | 299 B | 299 B | ✓ |
Overall change | 299 B | 299 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
index.html gzip | 585 B | 586 B | |
link.html gzip | 592 B | 593 B | |
withRouter.html gzip | 579 B | 580 B | |
Overall change | 1.76 kB | 1.76 kB |
Diffs
Diff for 677f882d2ed8..c23f838ed.js
@@ -714,8 +714,8 @@
}),
(e.addLocale = b),
(e.delLocale = _),
- (e.hasBasePath = P),
- (e.addBasePath = S),
+ (e.hasBasePath = S),
+ (e.addBasePath = P),
(e.delBasePath = k),
(e.isLocalURL = E),
(e.interpolateAs = R),
@@ -748,10 +748,10 @@
r = t.indexOf("#");
return (e > -1 || r > -1) && (t = t.substring(0, e > -1 ? e : r)), t;
}
- function P(t) {
+ function S(t) {
return "" === (t = x(t)) || t.startsWith("/");
}
- function S(t) {
+ function P(t) {
return (function(t, e) {
return e && t.startsWith("/")
? "/" === t
@@ -770,7 +770,7 @@
try {
var e = (0, h.getLocationOrigin)(),
r = new URL(t, e);
- return r.origin === e && P(r.pathname);
+ return r.origin === e && S(r.pathname);
} catch (n) {
return !1;
}
@@ -858,9 +858,9 @@
s = a.startsWith(c),
l = i && i.startsWith(c);
(a = C(a)), (i = i ? C(i) : i);
- var f = s ? a : S(a),
+ var f = s ? a : P(a),
p = r ? C(O(t.pathname, r)) : i || a;
- return { url: f, as: l ? p : S(p) };
+ return { url: f, as: l ? p : P(p) };
}
var T = Symbol("SSG_DATA_NOT_FOUND");
function I(t, e) {
@@ -947,7 +947,7 @@
s = i.query;
i.changeState(
"replaceState",
- (0, h.formatWithValidation)({ pathname: S(c), query: s }),
+ (0, h.formatWithValidation)({ pathname: P(c), query: s }),
(0, h.getURL)()
);
}
@@ -984,7 +984,7 @@
"//" !== n.substr(0, 2) &&
this.changeState(
"replaceState",
- (0, h.formatWithValidation)({ pathname: S(e), query: r }),
+ (0, h.formatWithValidation)({ pathname: P(e), query: r }),
(0, h.getURL)(),
{ locale: w }
),
@@ -1083,7 +1083,9 @@
);
case 3:
i._h && (this.isReady = !0),
- (i.scroll = !(null != (l = i.scroll) && !l)),
+ (i.scroll = !!(null != (l = i.scroll)
+ ? l
+ : !i.shallow)),
(f = i.locale !== this.locale),
(e.next = 18);
break;
@@ -1098,14 +1100,14 @@
this._inFlightRoute,
g
),
- (a = S(
+ (a = P(
b(
- P(a) ? k(a) : a,
+ S(a) ? k(a) : a,
i.locale,
this.defaultLocale
)
)),
- (w = _(P(a) ? k(a) : a, this.locale)),
+ (w = _(S(a) ? k(a) : a, this.locale)),
(this._inFlightRoute = a),
i._h || !this.onlyAHashChange(w))
) {
@@ -1313,45 +1315,41 @@
return (
t.events.emit("beforeHistoryChange", a, g),
this.changeState(r, o, a, i),
- (nt = i.shallow && this.route === D),
- (e.next = 114),
- this.set(
- D,
- C,
- I,
- w,
- V,
- u || (nt || !i.scroll ? null : { x: 0, y: 0 })
- ).catch(function(t) {
+ i.shallow && this.route === D,
+ (nt = i.scroll ? { x: 0, y: 0 } : null),
+ (e.next = 115),
+ this.set(D, C, I, w, V, u || nt).catch(function(
+ t
+ ) {
if (!t.cancelled) throw t;
z = z || t;
})
);
- case 114:
+ case 115:
if (!z) {
- e.next = 117;
+ e.next = 118;
break;
}
throw (t.events.emit("routeChangeError", z, w, g),
z);
- case 117:
+ case 118:
return (
t.events.emit("routeChangeComplete", a, g),
e.abrupt("return", !0)
);
- case 122:
+ case 123:
if (
- ((e.prev = 122),
+ ((e.prev = 123),
(e.t2 = e.catch(79)),
!e.t2.cancelled)
) {
- e.next = 126;
+ e.next = 127;
break;
}
return e.abrupt("return", !1);
- case 126:
- throw e.t2;
case 127:
+ throw e.t2;
+ case 128:
case "end":
return e.stop();
}
@@ -1360,7 +1358,7 @@
this,
[
[36, 46],
- [79, 122],
+ [79, 123],
[96, 102]
]
);
@@ -1620,6 +1618,7 @@
value: function(t, e, r, n, o, a) {
return (
(this.isFallback = !1),
+ console.log({ route: t, resetScroll: a }),
(this.route = t),
(this.pathname = e),
(this.query = r),
@@ -1689,7 +1688,7 @@
(0, p.isDynamicRoute)(e) &&
(0, m.getRouteRegex)(e).re.test(o)
)
- return (t.pathname = r ? S(e) : e), !0;
+ return (t.pathname = r ? P(e) : e), !0;
}),
(t.pathname = (0, c.removePathTrailingSlash)(t.pathname))),
t
@@ -2180,14 +2179,14 @@
_ = b && b(b(O([])));
_ && _ !== r && n.call(_, a) && (w = _);
var x = (g.prototype = y.prototype = Object.create(w));
- function P(t) {
+ function S(t) {
["next", "throw", "return"].forEach(function(e) {
c(t, e, function(t) {
return this._invoke(e, t);
});
});
}
- function S(t, e) {
+ function P(t, e) {
function r(o, a, i, u) {
var c = l(t[o], t, a);
if ("throw" !== c.type) {
@@ -2319,21 +2318,21 @@
(t.awrap = function(t) {
return { __await: t };
}),
- P(S.prototype),
- (S.prototype[i] = function() {
+ S(P.prototype),
+ (P.prototype[i] = function() {
return this;
}),
- (t.AsyncIterator = S),
+ (t.AsyncIterator = P),
(t.async = function(e, r, n, o, a) {
void 0 === a && (a = Promise);
- var i = new S(s(e, r, n, o), a);
+ var i = new P(s(e, r, n, o), a);
return t.isGeneratorFunction(r)
? i
: i.next().then(function(t) {
return t.done ? t.value : i.next();
});
}),
- P(x),
+ S(x),
c(x, u, "Generator"),
(x[a] = function() {
return this;
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f0ff32d677d75bce3a13.js"
as="script"
/>
<link
@@ -43,7 +43,7 @@
"props": { "pageProps": {} },
"page": "/",
"query": {},
- "buildId": "-MAVaVZ5qHf-x4qA8uAxZ",
+ "buildId": "ealq0J-zS_B4cDzy1vCmo",
"isFallback": false,
"gip": true
}
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f0ff32d677d75bce3a13.js"
async=""
></script>
<script
@@ -77,11 +77,11 @@
async=""
></script>
<script
- src="/_next/static/-MAVaVZ5qHf-x4qA8uAxZ/_buildManifest.js"
+ src="/_next/static/ealq0J-zS_B4cDzy1vCmo/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/-MAVaVZ5qHf-x4qA8uAxZ/_ssgManifest.js"
+ src="/_next/static/ealq0J-zS_B4cDzy1vCmo/_ssgManifest.js"
async=""
></script>
</body>
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f0ff32d677d75bce3a13.js"
as="script"
/>
<link
@@ -48,7 +48,7 @@
"props": { "pageProps": {} },
"page": "/link",
"query": {},
- "buildId": "-MAVaVZ5qHf-x4qA8uAxZ",
+ "buildId": "ealq0J-zS_B4cDzy1vCmo",
"isFallback": false,
"gip": true
}
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f0ff32d677d75bce3a13.js"
async=""
></script>
<script
@@ -82,11 +82,11 @@
async=""
></script>
<script
- src="/_next/static/-MAVaVZ5qHf-x4qA8uAxZ/_buildManifest.js"
+ src="/_next/static/ealq0J-zS_B4cDzy1vCmo/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/-MAVaVZ5qHf-x4qA8uAxZ/_ssgManifest.js"
+ src="/_next/static/ealq0J-zS_B4cDzy1vCmo/_ssgManifest.js"
async=""
></script>
</body>
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f0ff32d677d75bce3a13.js"
as="script"
/>
<link
@@ -43,7 +43,7 @@
"props": { "pageProps": {} },
"page": "/withRouter",
"query": {},
- "buildId": "-MAVaVZ5qHf-x4qA8uAxZ",
+ "buildId": "ealq0J-zS_B4cDzy1vCmo",
"isFallback": false,
"gip": true
}
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.c28076628b4c23f838ed.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.f0ff32d677d75bce3a13.js"
async=""
></script>
<script
@@ -77,11 +77,11 @@
async=""
></script>
<script
- src="/_next/static/-MAVaVZ5qHf-x4qA8uAxZ/_buildManifest.js"
+ src="/_next/static/ealq0J-zS_B4cDzy1vCmo/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/-MAVaVZ5qHf-x4qA8uAxZ/_ssgManifest.js"
+ src="/_next/static/ealq0J-zS_B4cDzy1vCmo/_ssgManifest.js"
async=""
></script>
</body>
haven't looked at the changes - but just to clarify: the issue #21606 this pr is referring to is not about disabling scroll-to-top for shallow routing (this is already the default behavior since 10.0.6-canary.8), but about allowing scroll-to-top for shallow routing when an explicit |
@@ -757,7 +757,7 @@ export default class Router implements BaseRouter { | |||
// Default to scroll reset behavior unless explicitly specified to be | |||
// `false`! This makes the behavior between using `Router#push` and a | |||
// `<Link />` consistent. | |||
options.scroll = !!(options.scroll ?? true) | |||
options.scroll = !!(options.scroll ?? (options.shallow ? false : true)) |
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.
Disable scroll
for shallow
links by default. Related to this change: #21437
Sorry for the unclear description. Updated. |
Failing test suitesCommit: fbc981c test/integration/create-next-app/index.test.js
Expand output● create next app › valid example
● create next app › should allow example with GitHub URL
● create next app › should allow example with GitHub URL and example-path
● create next app › should use --example-path over the file path in the GitHub URL
test/integration/build-output/test/index.test.js
Expand output● Build Output › Basic Application Output › should not deviate from snapshot
|
Stats from current PRDefault Server Mode (Increase detected
|
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
buildDuration | 10.6s | 10.6s | -51ms |
nodeModulesSize | 75.1 MB | 75.1 MB | -366 B |
Page Load Tests Overall increase ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.203 | 2.194 | -0.01 |
/ avg req/sec | 1134.76 | 1139.61 | +4.85 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.44 | 1.378 | -0.06 |
/error-in-render avg req/sec | 1736.28 | 1814.03 | +77.75 |
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
677f882d2ed8..49c4.js gzip | 13.1 kB | 13.1 kB | -10 B |
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.5 kB | 59.4 kB | -10 B |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Rendered Page Sizes Overall decrease ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
index.html gzip | 615 B | 614 B | -1 B |
link.html gzip | 621 B | 619 B | -2 B |
withRouter.html gzip | 609 B | 607 B | -2 B |
Overall change | 1.84 kB | 1.84 kB | -5 B |
Diffs
Diff for 677f882d2ed8..abf803634.js
@@ -1860,8 +1860,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
newUrl,
newAs,
notFoundRoute,
- appComp,
- isValidShallowRoute;
+ appComp;
return _regeneratorRuntime.wrap(
function _callee$(_context) {
@@ -1888,6 +1887,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
options.scroll = !!((_options$scroll =
options.scroll) != null
? _options$scroll
+ : options.shallow
+ ? false
: true);
localeChange = options.locale !== this.locale;
@@ -2325,11 +2326,9 @@ 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.
+ }
- isValidShallowRoute =
- options.shallow && this.route === route;
- _context.next = 114;
+ _context.next = 113;
return this.set(
route,
pathname,
@@ -2337,20 +2336,20 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
cleanedAs,
routeInfo,
forcedScroll ||
- (isValidShallowRoute || !options.scroll
- ? null
- : {
+ (options.scroll
+ ? {
x: 0,
y: 0
- })
+ }
+ : null)
)["catch"](function(e) {
if (e.cancelled) error = error || e;
else throw e;
});
- case 114:
+ case 113:
if (!error) {
- _context.next = 117;
+ _context.next = 116;
break;
}
@@ -2362,7 +2361,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
throw error;
- case 117:
+ case 116:
if (false) {
}
@@ -2373,21 +2372,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
);
return _context.abrupt("return", true);
- case 122:
- _context.prev = 122;
+ case 121:
+ _context.prev = 121;
_context.t2 = _context["catch"](79);
if (!_context.t2.cancelled) {
- _context.next = 126;
+ _context.next = 125;
break;
}
return _context.abrupt("return", false);
- case 126:
+ case 125:
throw _context.t2;
- case 127:
+ case 126:
case "end":
return _context.stop();
}
@@ -2397,7 +2396,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
this,
[
[36, 46],
- [79, 122],
+ [79, 121],
[96, 102]
]
);
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4c703037e67abf803634.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.dffff0a684ad63886f83.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4c703037e67abf803634.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.dffff0a684ad63886f83.js"
async=""
></script>
<script
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4c703037e67abf803634.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.dffff0a684ad63886f83.js"
as="script"
/>
<link
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4c703037e67abf803634.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.dffff0a684ad63886f83.js"
async=""
></script>
<script
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4c703037e67abf803634.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.dffff0a684ad63886f83.js"
as="script"
/>
<link
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4c703037e67abf803634.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.dffff0a684ad63886f83.js"
async=""
></script>
<script
Serverless Mode (Decrease detected ✓)
General Overall decrease ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
buildDuration | 12.9s | 12.8s | -108ms |
nodeModulesSize | 75.1 MB | 75.1 MB | -366 B |
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
677f882d2ed8..49c4.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..5e3b.js gzip | N/A | 13.1 kB | N/A |
Overall change | 59.5 kB | 59.4 kB | -10 B |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
_buildManifest.js gzip | 321 B | 321 B | ✓ |
Overall change | 321 B | 321 B | ✓ |
Serverless bundles Overall decrease ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | 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 | -136 B |
routerDirect.js | 1.06 MB | 1.05 MB | -136 B |
withRouter.js | 1.06 MB | 1.05 MB | -136 B |
Overall change | 5.19 MB | 5.19 MB | -408 B |
Webpack 5 Mode (Increase detected ⚠️ )
General Overall decrease ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
buildDuration | 13s | 13s | -26ms |
nodeModulesSize | 75.1 MB | 75.1 MB | -366 B |
Page Load Tests Overall increase ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
/ failed reqs | 0 | 0 | ✓ |
/ total time (seconds) | 2.147 | 2.131 | -0.02 |
/ avg req/sec | 1164.6 | 1173.14 | +8.54 |
/error-in-render failed reqs | 0 | 0 | ✓ |
/error-in-render total time (seconds) | 1.452 | 1.376 | -0.08 |
/error-in-render avg req/sec | 1721.23 | 1817.06 | +95.83 |
Client Bundles (main, webpack, commons) Overall decrease ✓
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
597-6c246419..806f.js gzip | 13 kB | 13 kB | -12 B |
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.9 kB | 59.8 kB | -12 B |
Legacy Client Bundles (polyfills)
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | 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 | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
_app-6e0a903..b885.js gzip | 1.26 kB | 1.26 kB | ✓ |
_error-7a100..a392.js gzip | 3.38 kB | 3.38 kB | ✓ |
hooks-f7e199..11b9.js gzip | 904 B | 904 B | ✓ |
index-3dc22c..ffbb.js gzip | 232 B | 232 B | ✓ |
link-c010d28..b60a.js gzip | 1.63 kB | 1.63 kB | ✓ |
routerDirect..323a.js gzip | 308 B | 308 B | ✓ |
withRouter-a..2ef8.js gzip | 304 B | 304 B | ✓ |
Overall change | 8.02 kB | 8.02 kB | ✓ |
Client Build Manifests
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
_buildManifest.js gzip | 299 B | 299 B | ✓ |
Overall change | 299 B | 299 B | ✓ |
Rendered Page Sizes Overall increase ⚠️
vercel/next.js canary | ekratskih/next.js fix/scroll-shallow | Change | |
---|---|---|---|
index.html gzip | 586 B | 587 B | |
link.html gzip | 593 B | 593 B | ✓ |
withRouter.html gzip | 579 B | 580 B | |
Overall change | 1.76 kB | 1.76 kB |
Diffs
Diff for 677f882d2ed8..dc0f149c4.js
@@ -1066,8 +1066,7 @@
K,
tt,
et,
- rt,
- nt;
+ rt;
return n.wrap(
function(e) {
for (;;)
@@ -1083,7 +1082,9 @@
);
case 3:
i._h && (this.isReady = !0),
- (i.scroll = !(null != (l = i.scroll) && !l)),
+ (i.scroll = !!(null != (l = i.scroll)
+ ? l
+ : !i.shallow)),
(f = i.locale !== this.locale),
(e.next = 18);
break;
@@ -1313,45 +1314,44 @@
return (
t.events.emit("beforeHistoryChange", a, g),
this.changeState(r, o, a, i),
- (nt = i.shallow && this.route === D),
- (e.next = 114),
+ (e.next = 113),
this.set(
D,
C,
I,
w,
V,
- u || (nt || !i.scroll ? null : { x: 0, y: 0 })
+ u || (i.scroll ? { x: 0, y: 0 } : null)
).catch(function(t) {
if (!t.cancelled) throw t;
z = z || t;
})
);
- case 114:
+ case 113:
if (!z) {
- e.next = 117;
+ e.next = 116;
break;
}
throw (t.events.emit("routeChangeError", z, w, g),
z);
- case 117:
+ case 116:
return (
t.events.emit("routeChangeComplete", a, g),
e.abrupt("return", !0)
);
- case 122:
+ case 121:
if (
- ((e.prev = 122),
+ ((e.prev = 121),
(e.t2 = e.catch(79)),
!e.t2.cancelled)
) {
- e.next = 126;
+ e.next = 125;
break;
}
return e.abrupt("return", !1);
- case 126:
+ case 125:
throw e.t2;
- case 127:
+ case 126:
case "end":
return e.stop();
}
@@ -1360,7 +1360,7 @@
this,
[
[36, 46],
- [79, 122],
+ [79, 121],
[96, 102]
]
);
Diff for index.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4256237aee7dc0f149c4.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2ff545bc57287125e3b.js"
as="script"
/>
<link
@@ -43,7 +43,7 @@
"props": { "pageProps": {} },
"page": "/",
"query": {},
- "buildId": "-FIaeXYplxDhVAsHvUO8b",
+ "buildId": "eJG6o5DfHVacg1YdFOyXi",
"isFallback": false,
"gip": true
}
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4256237aee7dc0f149c4.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2ff545bc57287125e3b.js"
async=""
></script>
<script
@@ -77,11 +77,11 @@
async=""
></script>
<script
- src="/_next/static/-FIaeXYplxDhVAsHvUO8b/_buildManifest.js"
+ src="/_next/static/eJG6o5DfHVacg1YdFOyXi/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/-FIaeXYplxDhVAsHvUO8b/_ssgManifest.js"
+ src="/_next/static/eJG6o5DfHVacg1YdFOyXi/_ssgManifest.js"
async=""
></script>
</body>
Diff for link.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4256237aee7dc0f149c4.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2ff545bc57287125e3b.js"
as="script"
/>
<link
@@ -48,7 +48,7 @@
"props": { "pageProps": {} },
"page": "/link",
"query": {},
- "buildId": "-FIaeXYplxDhVAsHvUO8b",
+ "buildId": "eJG6o5DfHVacg1YdFOyXi",
"isFallback": false,
"gip": true
}
@@ -70,7 +70,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4256237aee7dc0f149c4.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2ff545bc57287125e3b.js"
async=""
></script>
<script
@@ -82,11 +82,11 @@
async=""
></script>
<script
- src="/_next/static/-FIaeXYplxDhVAsHvUO8b/_buildManifest.js"
+ src="/_next/static/eJG6o5DfHVacg1YdFOyXi/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/-FIaeXYplxDhVAsHvUO8b/_ssgManifest.js"
+ src="/_next/static/eJG6o5DfHVacg1YdFOyXi/_ssgManifest.js"
async=""
></script>
</body>
Diff for withRouter.html
@@ -22,7 +22,7 @@
/>
<link
rel="preload"
- href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4256237aee7dc0f149c4.js"
+ href="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2ff545bc57287125e3b.js"
as="script"
/>
<link
@@ -43,7 +43,7 @@
"props": { "pageProps": {} },
"page": "/withRouter",
"query": {},
- "buildId": "-FIaeXYplxDhVAsHvUO8b",
+ "buildId": "eJG6o5DfHVacg1YdFOyXi",
"isFallback": false,
"gip": true
}
@@ -65,7 +65,7 @@
async=""
></script>
<script
- src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.4256237aee7dc0f149c4.js"
+ src="/_next/static/chunks/677f882d2ed86fa3467b8979053c1a4c3f8bc4df.d2ff545bc57287125e3b.js"
async=""
></script>
<script
@@ -77,11 +77,11 @@
async=""
></script>
<script
- src="/_next/static/-FIaeXYplxDhVAsHvUO8b/_buildManifest.js"
+ src="/_next/static/eJG6o5DfHVacg1YdFOyXi/_buildManifest.js"
async=""
></script>
<script
- src="/_next/static/-FIaeXYplxDhVAsHvUO8b/_ssgManifest.js"
+ src="/_next/static/eJG6o5DfHVacg1YdFOyXi/_ssgManifest.js"
async=""
></script>
</body>
has this been fixed? |
@ekratskih why did you close this? It's still an issue as of next version 10.2 |
Allow scroll-to-top for shallow routing when an explicit
scroll: true
option is provided.Fix for the issue: #21606