Is it possible to manually manage the state of NavigationMenuTrigger
?
#892
Unanswered
feryardiant
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there,
I'm new to radix-vue, just messing around with it for couple days on my existing project. Came across an issue where I need to gain more control of the state of
NavigationMenuTrigger
. Precicely thedata-state="closed"
andaria-expanded="false"
attributes, which is can only be changed via user interaction (eitherhover
orclick
). Please correct me if i'm wrong 🙏🏼Suppose I have a side-navigation and store the navigation state in localStorage
activeKey
andexpandKeys
.activeKey
contains the menu key (id) that currently active, andexpandKeys
contains the array of string parent menu key (id). Let say my menu looks like these :When I click the
Sub Menu One First
link I'll store the key ofMenu One
toexpandKeys
and the key ofSub Menu One First
inactiveKey
. So when I reload the page I could easily find which sub-menu to expand and wich sub-menu item to be active.As far as my understanding of the documentation and the codebase, I can't see any clue to manually set
data-state
andaria-expanded
value unless usingref
but I'm not sure whether it will be overwrited byhover
orclick
interaction to the menu trigger.===
Update 23 May 24
Screen.Recording.2024-05-23.at.16.14.01.mov
For context, I'm having hard time figuuring out the way to implement vertical sidenav that will expanded when have it's submenu item activated.
Tried to use
force-mount
props on theNavigationMenuSub
component, but theirdata-state
is remainclosed
andaria-expanded
isfalse
.Can anyone enlighten me 🙏🏼
Beta Was this translation helpful? Give feedback.
All reactions