Basic file-based example layout-b loses active state
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.1k
- Forks
- 1.9k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 143
Description
Which project does this relate to?
Router
Describe the bug
I am learning how to use tanstack-router, and was looking at the basic file-based example. I noticed that when navigating to layout-b, the active styles are lost in the navigation bar at the top. It seems this is because Layout is directly linking to layout-a, so when /layout-b is visited, it's no longer active.
I think this example should be improved to demonstrate how one might keep the nav link active, while still navigating to sub-routes. I suppose the way this would be done in practice is to add a layouts.tsx without the prefix, and then both layout-a and layout-b would be nested under that, right?
Or maybe I'm missing the point, and the whole idea of this section of the example is to show that prefixed layouts are not considered in the URL.
Your Example Website or App
https://tanstack.com/router/latest/docs/framework/react/examples/basic-file-based
Steps to Reproduce the Bug or Issue
Go to the example, click Layout, then in the page, click "Layout B". The active styles are lost from "Layout" at the top of the page.
Expected behavior
I expected "Layout" to not lose its active styles.
Screenshots or Videos
No response
Platform
NA
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the basic file-based example in the linked Router documentation and reproduce the Layout → Layout B navigation described in the issue. Inspect how the example defines the Layout navigation and nested routes; done means the top-level Layout link retains its active styles while navigating to Layout B.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100