Skip to content

Conversation

nlynzaad
Copy link
Contributor

As part of commit #4573 we enhanced to process of determining when routes are changing, this especially enhanced the functioning of to="." route paths.

It was assumed that routing to a "." path should only be required to reload the current location and any navigation to other routes should be done with explicitly defining an absolute or relative route in the "to" path.

While this is still the recommended option, #4842 has pointed out that this is an unintended regression and that certain circumstances might require applying the to="." navigation on explicitly defined "from" route paths.

This requires us to be aware of the fact that from is explicitly defined and that the to="." navigation should be applied on this specified location. The from location is unfortunately determined higher up in the chain, in the Link component and useNavigate hook, and the history of the source of this from location is therefore lost before the navigation location is built.

This PR resolves #4842 by passing a new optional paramater "_isDefinedFrom" to the navigate function which in turn passes this to buildLocation. This enables buildLocation to make allowance for the fact that the "from" path is explicitly defined and uses this in determining if navigation is causing a route change or merely reloading the current location.

This PR also adds an additional unit test on useNavigate to ensure the regression does not repeat in future. It also updates the documentation to reflect this added functionality as well as the recommended way of navigation to other locations.

Copy link

nx-cloud bot commented Aug 12, 2025

View your CI Pipeline Execution ↗ for commit fbe8fab

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 3m 59s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 35s View ↗

☁️ Nx Cloud last updated this comment at 2025-08-12 21:23:46 UTC

Copy link

pkg-pr-new bot commented Aug 12, 2025

More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@4937

@tanstack/directive-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@4937

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@4937

@tanstack/history

npm i https://pkg.pr.new/TanStack/router/@tanstack/history@4937

@tanstack/react-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@4937

@tanstack/react-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@4937

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@4937

@tanstack/react-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@4937

@tanstack/react-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@4937

@tanstack/react-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-plugin@4937

@tanstack/react-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@4937

@tanstack/router-cli

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@4937

@tanstack/router-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@4937

@tanstack/router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@4937

@tanstack/router-devtools-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@4937

@tanstack/router-generator

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@4937

@tanstack/router-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@4937

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@4937

@tanstack/router-utils

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@4937

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@4937

@tanstack/server-functions-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@4937

@tanstack/solid-router

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@4937

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@4937

@tanstack/solid-start

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@4937

@tanstack/solid-start-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@4937

@tanstack/solid-start-plugin

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-plugin@4937

@tanstack/solid-start-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@4937

@tanstack/start-client-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@4937

@tanstack/start-plugin-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@4937

@tanstack/start-server-core

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@4937

@tanstack/start-server-functions-client

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-client@4937

@tanstack/start-server-functions-fetcher

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-fetcher@4937

@tanstack/start-server-functions-server

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-functions-server@4937

@tanstack/start-storage-context

npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@4937

@tanstack/valibot-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@4937

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@4937

@tanstack/zod-adapter

npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@4937

commit: fbe8fab

@nlynzaad nlynzaad marked this pull request as draft August 12, 2025 23:29
@nlynzaad
Copy link
Contributor Author

setting this as draft, we need to look into it a bit deeper. this solution is not ideal

@nlynzaad
Copy link
Contributor Author

nlynzaad commented Aug 17, 2025

closing this in favour of #4978

@nlynzaad nlynzaad closed this Aug 17, 2025
@nlynzaad nlynzaad deleted the Issue-4842 branch August 17, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relative routing to index route does not navigate
1 participant