-
Notifications
You must be signed in to change notification settings - Fork 66
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
[SideNav] Allow matching routes with dynamic parameters #5227
[SideNav] Allow matching routes with dynamic parameters #5227
Comments
One additional thing to keep in mind is that the additional paths might or might not be based on the same view class. In other words, there are two different ways of implementing the case described here:
In either case, the item that links to Could also note that it seems like this almost works already since the previous item remains highlighted after navigation (probably because no other item was highlighted) but there will be no highlighted item after reloading the page. |
I am very much in favour of this being implemented. I'd even argue this is a bug as the documentation has no qualifying statement that this is limited to particular types of routes. |
Describe your motivation
Currently side nav items need a concrete URL without parameters / placeholders in order to determine whether they match the current URL and should thus be highlighted. However you might also want an item to match a route with dynamic path parameters, where the parameter can take an unknown number of values.
For example, an application could have:
/products
/products/:productId
In that case you might want to use a single nav item "Products" that matches both:
/products
/products/:productId
/products/1
,/products/2
,/products/3
, ...Describe the solution you'd like
I can think of two solutions:
current
state of each item manually. For example, allow to provide a callback for each item that calculates whether the item matches the current route or not. When navigation happens, run each callback and set thecurrent
state based on the result. While not as convenient as the first option, this would be more flexible and could handle complex cases that we can not anticipate or support with a generic matching implementation.Describe alternatives you've considered
No response
Additional context
Dynamic parameters can not be part of the "main" path, as we need a concrete URL here for the side nav item's anchor tag, so these can only be supported for path aliases.
The text was updated successfully, but these errors were encountered: