Add helper for automatically highlighting the active item in a menu
See original GitHub issueAutomatically highlighting the active part in e.g. a menu hierarchy can already be done manually by making the menu or individual links implement AfterNavigationObserver
and then manually toggle a css classname or an attribute.
In the general case, menu items can be represented by any kind of component and there can also be arbitrary logic for when a section is considered to be active. In practice, the menu items are usually RouterLink
components and the hierarchy is either defined based on the URL structure or sharing a common RouterLayout
(though in most cases the topmost layout is shared among the entire application).
We could add helper API to RouterLink
for the common cases and ensure the documentation also contains an example of how this is done manually.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:9 (9 by maintainers)
Some ideas on what the API in
RouterLink
could look like:Edit: Renamed APIs to use
highlight
instead ofactive
Anything that is currently attached to the component tree will receive navigation events if they implement the appropriate interface.