Skip to content

Conversation

ChanDarong
Copy link

@ChanDarong ChanDarong commented Sep 8, 2025

This pull request updates the logic for checking if a URL is active in the urlIsActive utility function to provide more accurate matching, especially for root and subpath URLs.

Navigation logic improvements:

  • Updated the urlIsActive function in resources/js/lib/utils.ts to ensure that the root path '/' only matches itself, and that non-root paths match if the current URL starts with the checked URL. This provides more intuitive active link highlighting for navigation.
  • Usefull for the nav bar, because we want to keep the nav bar active in many route in a CRUD, example /admin/users, /admin/users/create, /admin/users/1/edit, etc.

@joetannenbaum
Copy link
Contributor

I get your reasoning, but I think sometimes you wan to know if that exact URL is active, which is what this currently does. I don't mind adding a flag param to this helper to match exact or subpaths (or perhaps even making an additional helper for the subpath checking).

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