@tanstack/router-core 0.0.1-beta.201 → 0.0.1-beta.203

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.
@@ -1004,6 +1004,7 @@ class Router {
1004
1004
  const fromPathname = dest.from ?? from.pathname;
1005
1005
  let pathname = path.resolvePath(this.basepath ?? '/', fromPathname, `${dest.to ?? ''}`);
1006
1006
  const fromMatches = this.matchRoutes(fromPathname, from.search);
1007
+ const stayingMatches = matches?.filter(d => fromMatches?.find(e => e.routeId === d.routeId));
1007
1008
  const prevParams = {
1008
1009
  ...utils.last(fromMatches)?.params
1009
1010
  };
@@ -1017,8 +1018,8 @@ class Router {
1017
1018
  });
1018
1019
  }
1019
1020
  pathname = path.interpolatePath(pathname, nextParams ?? {});
1020
- const preSearchFilters = matches?.map(match => this.getRoute(match.routeId).options.preSearchFilters ?? []).flat().filter(Boolean) ?? [];
1021
- const postSearchFilters = matches?.map(match => this.getRoute(match.routeId).options.postSearchFilters ?? []).flat().filter(Boolean) ?? [];
1021
+ const preSearchFilters = stayingMatches?.map(match => this.getRoute(match.routeId).options.preSearchFilters ?? []).flat().filter(Boolean) ?? [];
1022
+ const postSearchFilters = stayingMatches?.map(match => this.getRoute(match.routeId).options.postSearchFilters ?? []).flat().filter(Boolean) ?? [];
1022
1023
 
1023
1024
  // Pre filters first
1024
1025
  const preFilteredSearch = preSearchFilters?.length ? preSearchFilters?.reduce((prev, next) => next(prev), from.search) : from.search;
@@ -1107,36 +1108,35 @@ class Router {
1107
1108
 
1108
1109
  // If the next urls are the same and we're not replacing,
1109
1110
  // do nothing
1110
- if (isSameUrl && !next.replace) {
1111
- return;
1112
- }
1113
- let {
1114
- maskedLocation,
1115
- ...nextHistory
1116
- } = next;
1117
- if (maskedLocation) {
1118
- nextHistory = {
1119
- ...maskedLocation,
1120
- state: {
1121
- ...maskedLocation.state,
1122
- __tempKey: undefined,
1123
- __tempLocation: {
1124
- ...nextHistory,
1125
- search: nextHistory.searchStr,
1126
- state: {
1127
- ...nextHistory.state,
1128
- __tempKey: undefined,
1129
- __tempLocation: undefined,
1130
- key: undefined
1111
+ if (!isSameUrl || next.replace) {
1112
+ let {
1113
+ maskedLocation,
1114
+ ...nextHistory
1115
+ } = next;
1116
+ if (maskedLocation) {
1117
+ nextHistory = {
1118
+ ...maskedLocation,
1119
+ state: {
1120
+ ...maskedLocation.state,
1121
+ __tempKey: undefined,
1122
+ __tempLocation: {
1123
+ ...nextHistory,
1124
+ search: nextHistory.searchStr,
1125
+ state: {
1126
+ ...nextHistory.state,
1127
+ __tempKey: undefined,
1128
+ __tempLocation: undefined,
1129
+ key: undefined
1130
+ }
1131
1131
  }
1132
1132
  }
1133
+ };
1134
+ if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) {
1135
+ nextHistory.state.__tempKey = this.tempLocationKey;
1133
1136
  }
1134
- };
1135
- if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) {
1136
- nextHistory.state.__tempKey = this.tempLocationKey;
1137
1137
  }
1138
+ this.history[next.replace ? 'replace' : 'push'](nextHistory.href, nextHistory.state);
1138
1139
  }
1139
- this.history[next.replace ? 'replace' : 'push'](nextHistory.href, nextHistory.state);
1140
1140
  this.resetNextScroll = next.resetScroll ?? true;
1141
1141
  return this.latestLoadPromise;
1142
1142
  };