Skip to content

Controlling Menu component state for indirect open/closing #2862

Answered by gloriliale
oscar8880 asked this question in General
Discussion options

You must be logged in to vote

Hi @oscar8880! Thank you so much for your patience. We used your CodeSandbox as the basis for our own working example in this one!

Our Menu component is made through our Menu Primitive which repackages Reakit's menu, so their docs would be the best place to find details about controlling the menu state. We can use toggle within the menu state, for example, instead of creating a separate state for it opening and closing.

Two things to note about accessibility:

  • We need to ensure that when the menu opens from the external trigger, like the button in this example, that the first item in the menu is focused, so that a user can then use the down arrow key to navigate through it. We're able to …

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@oscar8880
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@hjbrown11
Comment options

@gloriliale
Comment options

Answer selected by gloriliale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants