TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
7.19k stars 486 forks source link

`navigate` functions without `to` but with `search` causes a route error inside a layout route. #1560

Closed ruiaraujo012 closed 2 weeks ago

ruiaraujo012 commented 2 weeks ago

Describe the bug

After version 1.31.7 the error started occurring. Related to #1548. @SeanCassiere

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-1udi7f?file=src%2Froutes%2F_test%2Ftabs-example.%24someId.tsx

Steps to Reproduce the Bug or Issue

Go to "Tabs example" route, change the tab and the error is caused. If you put the URL manually, let's say ...?tab=tab2 it renders well, but as soon as you change the tab the app crash

Expected behavior

Both tabs work well without crashing the app.

Screenshots or Videos

No response

Platform

Additional context

No response

SeanCassiere commented 2 weeks ago

It has to do with this line.

For the fromPath it currently resolves to using the routeId of of the current route, which contains the layout identifier as a part of it.

It'll be matter of either sanitizing whats returned by the routeId or seeing if there's another property on the match that can be used here.

SeanCassiere commented 2 weeks ago

This has been fixed and released in 1.31.19.

ruiaraujo012 commented 2 weeks ago

Thanks, I appreciated it.

tatwater commented 1 week ago

I'm on 1.31.28 and I'm still experiencing this same bug! Routes that have an id instead of a path are getting their id inserted into the URL when navigating with search params, which errors.

SeanCassiere commented 1 week ago

I'm on 1.31.28 and I'm still experiencing this same bug! Routes that have an id instead of a path are getting their id inserted into the URL when navigating with search params, which errors.

This has been fixed as of the 1.31.29 release.