-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(router-core): useBlocker navigation issues for 404 pages and external URLs #4917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jiji-hoon96
wants to merge
3
commits into
TanStack:main
Choose a base branch
from
jiji-hoon96:feat/useBlocker-navigation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+196
−9
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View your CI Pipeline Execution ↗ for commit 4ddec20
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-ssr-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-plugin
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-ssr-query-core
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-plugin
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-server-functions-client
@tanstack/start-server-functions-fetcher
@tanstack/start-server-functions-server
@tanstack/start-storage-context
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two critical navigation issues with the useBlocker hook:
404 Page Navigation: Previously, when a user was on a 404 page with an active blocker, attempting to navigate to any other page would throw an error:
"Error: No route found for location /foo"
External URL ignoreBlocker: The
ignoreBlocker
option was not respected for external URLs, causing blockers to still prevent navigation even when explicitly ignoredChanges
404 Page Navigation Fix
foundRoute
isundefined
by returningrouteId: '__notFound__'
External URL ignoreBlocker Fix
ignoreBlocker
option for external URLsignoreBlocker
is falseTest Coverage
Technical Details
404 Page Navigation
Root Cause: The blocker was trying to resolve 404 paths as valid routes, causing errors when getMatchedRoutes returned
undefined
forfoundRoute
.Solution: The getLocation function now:
routeId: '__notFound__'
for unmatched routesExternal URL ignoreBlocker
Root Cause: External URL navigation bypassed the normal blocker flow and didn't check the
ignoreBlocker
option.Solution: The navigate function now:
ignoreBlocker: true
true
, proceeds if all allowBreaking Changes
None. All existing functionality is preserved and the API remains unchanged.
Fixes
beforeunload
dialog triggered by redirect to external site even after original blocker proceed occurs #4094 (I think it's a similar issue.)