@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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.168",
4
+ "version": "0.0.1-beta.169",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -43,7 +43,7 @@
43
43
  "tiny-invariant": "^1.3.1",
44
44
  "tiny-warning": "^1.0.3",
45
45
  "@gisatcz/cross-package-react-context": "^0.2.0",
46
- "@tanstack/react-store": "0.0.1-beta.168"
46
+ "@tanstack/react-store": "0.0.1-beta.169"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "rollup --config rollup.config.js",
package/src/link.ts CHANGED
@@ -124,6 +124,7 @@ export type NavigateOptions<
124
124
  > = ToOptions<TRouteTree, TFrom, TTo> & {
125
125
  // `replace` is a boolean that determines whether the navigation should replace the current history entry or push a new one.
126
126
  replace?: boolean
127
+ resetScroll?: boolean
127
128
  }
128
129
 
129
130
  export type ToOptions<
package/src/router.ts CHANGED
@@ -318,6 +318,7 @@ export class Router<
318
318
  __store: Store<RouterState<TRouteTree>>
319
319
  state: RouterState<TRouteTree>
320
320
  dehydratedData?: TDehydrated
321
+ resetNextScroll = false
321
322
 
322
323
  constructor(options: RouterConstructorOptions<TRouteTree, TDehydrated>) {
323
324
  this.options = {
@@ -1124,6 +1125,7 @@ export class Router<
1124
1125
  hash,
1125
1126
  replace,
1126
1127
  params,
1128
+ resetScroll,
1127
1129
  }: NavigateOptions<TRouteTree, TFrom, TTo>) => {
1128
1130
  // If this link simply reloads the current route,
1129
1131
  // make sure it has a new key so it will trigger a data refresh
@@ -1151,6 +1153,7 @@ export class Router<
1151
1153
  hash,
1152
1154
  replace,
1153
1155
  params,
1156
+ resetScroll,
1154
1157
  })
1155
1158
  }
1156
1159
 
@@ -1214,6 +1217,7 @@ export class Router<
1214
1217
  preloadDelay: userPreloadDelay,
1215
1218
  disabled,
1216
1219
  state,
1220
+ resetScroll,
1217
1221
  }: LinkOptions<TRouteTree, TFrom, TTo>): LinkInfo => {
1218
1222
  // If this link simply reloads the current route,
1219
1223
  // make sure it has a new key so it will trigger a data refresh
@@ -1237,6 +1241,7 @@ export class Router<
1237
1241
  hash,
1238
1242
  replace,
1239
1243
  state,
1244
+ resetScroll,
1240
1245
  }
1241
1246
 
1242
1247
  const next = this.buildNext(nextOpts)
@@ -1676,7 +1681,7 @@ export class Router<
1676
1681
  }
1677
1682
 
1678
1683
  #commitLocation = async (
1679
- location: BuildNextOptions & { replace?: boolean },
1684
+ location: BuildNextOptions & { replace?: boolean; resetScroll?: boolean },
1680
1685
  ) => {
1681
1686
  const next = this.buildNext(location)
1682
1687
  const id = '' + Date.now() + Math.random()
@@ -1704,6 +1709,9 @@ export class Router<
1704
1709
  ...next.state,
1705
1710
  })
1706
1711
 
1712
+ this.resetNextScroll = location.resetScroll ?? true
1713
+ console.log('resetScroll', this.resetNextScroll)
1714
+
1707
1715
  return this.latestLoadPromise
1708
1716
  }
1709
1717
 
@@ -144,6 +144,10 @@ export function restoreScrollPositions(
144
144
  opts?: ScrollRestorationOptions,
145
145
  ) {
146
146
  if (pathDidChange) {
147
+ if (!router.resetNextScroll) {
148
+ return
149
+ }
150
+
147
151
  const getKey = opts?.getKey || defaultGetKey
148
152
 
149
153
  pathDidChange = false