Skip to content
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

add toPrefix to NavLinks in Sidebar to better highlight isActive #2748

Merged
merged 3 commits into from
Mar 7, 2025

Conversation

charliepark
Copy link
Contributor

This fixes an issue that we were seeing with tabbed pages, where the sidebar navigation wasn't working as expected for tabbed pages.

Note how the "Inventory" link is "active" for the Sleds tab, but not the Disks tab:
Screenshot 2025-03-06 at 2 45 37 PM
Screenshot 2025-03-06 at 2 45 42 PM

This PR fixes NavLinks in the Sidebar by adding a toPrefix, which is essentially the first part of a URL path. If a link is given a toPrefix prop, that more generic string will be used when the component is determining if the tab should be rendered as "active" or not.

Here it is, fixed:
navlinks

Copy link

vercel bot commented Mar 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Mar 7, 2025 1:31am

@david-crespo
Copy link
Collaborator

Looks good. What do you think about renaming toPrefix to activePrefix (both here and on the existing RouteTab one)? I came up with toPrefix but in hindsight it would be good to say what it’s for right in the name.

@charliepark
Copy link
Contributor Author

Yeah, agree that that's better. Will pick that up before merge.

@charliepark charliepark enabled auto-merge (squash) March 7, 2025 01:33
@charliepark charliepark merged commit 5241ad7 into main Mar 7, 2025
7 checks passed
@charliepark charliepark deleted the better-sidebar-nav-activity branch March 7, 2025 02:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants