@tanstack/router-core 1.134.13 → 1.134.18

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.
@@ -271,13 +271,24 @@ class RouterCore {
271
271
  match._nonReactive.pendingTimeout = void 0;
272
272
  };
273
273
  this.cancelMatches = () => {
274
- this.state.pendingMatches?.forEach((match) => {
274
+ const currentPendingMatches = this.state.matches.filter(
275
+ (match) => match.status === "pending"
276
+ );
277
+ const currentLoadingMatches = this.state.matches.filter(
278
+ (match) => match.isFetching === "loader"
279
+ );
280
+ const matchesToCancelArray = /* @__PURE__ */ new Set([
281
+ ...this.state.pendingMatches ?? [],
282
+ ...currentPendingMatches,
283
+ ...currentLoadingMatches
284
+ ]);
285
+ matchesToCancelArray.forEach((match) => {
275
286
  this.cancelMatch(match.id);
276
287
  });
277
288
  };
278
289
  this.buildLocation = (opts) => {
279
290
  const build = (dest = {}) => {
280
- const currentLocation = dest._fromLocation || this.latestLocation;
291
+ const currentLocation = dest._fromLocation || this.pendingBuiltLocation || this.latestLocation;
281
292
  const allCurrentLocationMatches = this.matchRoutes(currentLocation, {
282
293
  _buildLocation: true
283
294
  });
@@ -515,7 +526,8 @@ class RouterCore {
515
526
  ...rest,
516
527
  _includeValidateSearch: true
517
528
  });
518
- return this.commitLocation({
529
+ this.pendingBuiltLocation = location;
530
+ const commitPromise = this.commitLocation({
519
531
  ...location,
520
532
  viewTransition,
521
533
  replace,
@@ -523,6 +535,12 @@ class RouterCore {
523
535
  hashScrollIntoView,
524
536
  ignoreBlocker
525
537
  });
538
+ Promise.resolve().then(() => {
539
+ if (this.pendingBuiltLocation === location) {
540
+ this.pendingBuiltLocation = void 0;
541
+ }
542
+ });
543
+ return commitPromise;
526
544
  };
527
545
  this.navigate = ({ to, reloadDocument, href, ...rest }) => {
528
546
  if (!reloadDocument && href) {