@tanstack/react-router 0.0.1-beta.254 → 0.0.1-beta.255

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.
@@ -2224,9 +2224,10 @@
2224
2224
  buildLocation = opts => {
2225
2225
  const build = (dest = {}, matches) => {
2226
2226
  const from = this.latestLocation;
2227
+ const fromSearch = (this.state.pendingMatches || this.state.matches).at(-1)?.search || from.search;
2227
2228
  const fromPathname = dest.from ?? from.pathname;
2228
2229
  let pathname = this.resolvePathWithBase(fromPathname, `${dest.to ?? ''}`);
2229
- const fromMatches = this.matchRoutes(fromPathname, from.search);
2230
+ const fromMatches = this.matchRoutes(fromPathname, fromSearch);
2230
2231
  const stayingMatches = matches?.filter(d => fromMatches?.find(e => e.routeId === d.routeId));
2231
2232
  const prevParams = {
2232
2233
  ...last(fromMatches)?.params
@@ -2245,7 +2246,7 @@
2245
2246
  const postSearchFilters = stayingMatches?.map(match => this.looseRoutesById[match.routeId].options.postSearchFilters ?? []).flat().filter(Boolean) ?? [];
2246
2247
 
2247
2248
  // Pre filters first
2248
- const preFilteredSearch = preSearchFilters?.length ? preSearchFilters?.reduce((prev, next) => next(prev), from.search) : from.search;
2249
+ const preFilteredSearch = preSearchFilters?.length ? preSearchFilters?.reduce((prev, next) => next(prev), fromSearch) : fromSearch;
2249
2250
 
2250
2251
  // Then the link/navigate function
2251
2252
  const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
@@ -2255,7 +2256,7 @@
2255
2256
 
2256
2257
  // Then post filters
2257
2258
  const postFilteredSearch = postSearchFilters?.length ? postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
2258
- const search = replaceEqualDeep(from.search, postFilteredSearch);
2259
+ const search = replaceEqualDeep(fromSearch, postFilteredSearch);
2259
2260
  const searchStr = this.options.stringifySearch(search);
2260
2261
  const hash = dest.hash === true ? from.hash : dest.hash ? functionalUpdate(dest.hash, from.hash) : from.hash;
2261
2262
  const hashStr = hash ? `#${hash}` : '';