@tanstack/router-core 1.139.1 → 1.139.3

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.
@@ -528,7 +528,7 @@ class RouterCore {
528
528
  });
529
529
  return commitPromise;
530
530
  };
531
- this.navigate = ({ to, reloadDocument, href, ...rest }) => {
531
+ this.navigate = async ({ to, reloadDocument, href, ...rest }) => {
532
532
  if (!reloadDocument && href) {
533
533
  try {
534
534
  new URL(`${href}`);
@@ -541,6 +541,23 @@ class RouterCore {
541
541
  const location = this.buildLocation({ to, ...rest });
542
542
  href = location.url;
543
543
  }
544
+ if (!rest.ignoreBlocker) {
545
+ const historyWithBlockers = this.history;
546
+ const blockers = historyWithBlockers.getBlockers?.() ?? [];
547
+ for (const blocker of blockers) {
548
+ if (blocker?.blockerFn) {
549
+ const shouldBlock = await blocker.blockerFn({
550
+ currentLocation: this.latestLocation,
551
+ nextLocation: this.latestLocation,
552
+ // External URLs don't have a next location in our router
553
+ action: "PUSH"
554
+ });
555
+ if (shouldBlock) {
556
+ return Promise.resolve();
557
+ }
558
+ }
559
+ }
560
+ }
544
561
  if (rest.replace) {
545
562
  window.location.replace(href);
546
563
  } else {