@tanstack/router-core 0.0.1-beta.168 → 0.0.1-beta.169
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/router.js +11 -4
- package/build/cjs/router.js.map +1 -1
- package/build/cjs/scroll-restoration.js +3 -0
- package/build/cjs/scroll-restoration.js.map +1 -1
- package/build/esm/index.js +14 -4
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +132 -132
- package/build/types/index.d.ts +4 -2
- package/build/umd/index.development.js +14 -4
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/link.ts +1 -0
- package/src/router.ts +9 -1
- package/src/scroll-restoration.ts +4 -0
package/build/esm/index.js
CHANGED
|
@@ -711,6 +711,7 @@ function stringifySearchWith(stringify, parser) {
|
|
|
711
711
|
const componentTypes = ['component', 'errorComponent', 'pendingComponent'];
|
|
712
712
|
class Router {
|
|
713
713
|
#unsubHistory;
|
|
714
|
+
resetNextScroll = false;
|
|
714
715
|
constructor(options) {
|
|
715
716
|
this.options = {
|
|
716
717
|
defaultPreloadDelay: 50,
|
|
@@ -1313,7 +1314,8 @@ class Router {
|
|
|
1313
1314
|
search,
|
|
1314
1315
|
hash,
|
|
1315
1316
|
replace,
|
|
1316
|
-
params
|
|
1317
|
+
params,
|
|
1318
|
+
resetScroll
|
|
1317
1319
|
}) => {
|
|
1318
1320
|
// If this link simply reloads the current route,
|
|
1319
1321
|
// make sure it has a new key so it will trigger a data refresh
|
|
@@ -1334,7 +1336,8 @@ class Router {
|
|
|
1334
1336
|
search,
|
|
1335
1337
|
hash,
|
|
1336
1338
|
replace,
|
|
1337
|
-
params
|
|
1339
|
+
params,
|
|
1340
|
+
resetScroll
|
|
1338
1341
|
});
|
|
1339
1342
|
};
|
|
1340
1343
|
matchRoute = (location, opts) => {
|
|
@@ -1374,7 +1377,8 @@ class Router {
|
|
|
1374
1377
|
preload,
|
|
1375
1378
|
preloadDelay: userPreloadDelay,
|
|
1376
1379
|
disabled,
|
|
1377
|
-
state
|
|
1380
|
+
state,
|
|
1381
|
+
resetScroll
|
|
1378
1382
|
}) => {
|
|
1379
1383
|
// If this link simply reloads the current route,
|
|
1380
1384
|
// make sure it has a new key so it will trigger a data refresh
|
|
@@ -1396,7 +1400,8 @@ class Router {
|
|
|
1396
1400
|
params,
|
|
1397
1401
|
hash,
|
|
1398
1402
|
replace,
|
|
1399
|
-
state
|
|
1403
|
+
state,
|
|
1404
|
+
resetScroll
|
|
1400
1405
|
};
|
|
1401
1406
|
const next = this.buildNext(nextOpts);
|
|
1402
1407
|
preload = preload ?? this.options.defaultPreload;
|
|
@@ -1714,6 +1719,8 @@ class Router {
|
|
|
1714
1719
|
id,
|
|
1715
1720
|
...next.state
|
|
1716
1721
|
});
|
|
1722
|
+
this.resetNextScroll = location.resetScroll ?? true;
|
|
1723
|
+
console.log('resetScroll', this.resetNextScroll);
|
|
1717
1724
|
return this.latestLoadPromise;
|
|
1718
1725
|
};
|
|
1719
1726
|
getRouteMatch = id => {
|
|
@@ -1932,6 +1939,9 @@ function watchScrollPositions(router, opts) {
|
|
|
1932
1939
|
}
|
|
1933
1940
|
function restoreScrollPositions(router, opts) {
|
|
1934
1941
|
if (pathDidChange) {
|
|
1942
|
+
if (!router.resetNextScroll) {
|
|
1943
|
+
return;
|
|
1944
|
+
}
|
|
1935
1945
|
const getKey = opts?.getKey || defaultGetKey;
|
|
1936
1946
|
pathDidChange = false;
|
|
1937
1947
|
const restoreKey = getKey(router.state.location);
|