[NavigationMenu] Menu should close when navigating to a `Link`
See original GitHub issueFeature request
Overview
Add open
state to NavigationMenu.Root
so we can override opening/closing states for use with external lib (e.g. Framer Motion).
Same functionality as found in Collapsible
, DropdownMenu
, Dialog
, etc.
Edit: There’s also no way of closing the menu when navigation between pages in a Next.js app and the menu stays open (located in global layout outside page content)
Thank you!
Issue Analytics
- State:
- Created a year ago
- Comments:8
Top Results From Across the Web
html - How do I close the entire navigation when a link (nav ...
In a nutshell, I want the navigation menu to close and when a link is clicked. My HTML code <input type="checkbox" class="navigation__checkbox ...
Read more >How to let mobile navigation menu close when link is clicked?
I would use javascript (or jQuery) to detect when the menu item is clicked and close the menu. $( '.menu-item' ).on( 'click', function(e){ ......
Read more >Navigation Menu Button Example | APG | WAI - W3C
Activates the menu item, which is equivalent to activating the link element from which the menu item is made. Escape. Closes the menu....
Read more >How to close a navigation menu when the page is clicked
... a working navigation menu on your website that can be opened and closed ... The event will fire when any part of...
Read more >Closing a navigation menu in React - DEV Community
Closing a navigation menu in React ... you go to a new page (or would if they weren't dummy links) and the menu...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks for this! i implemented a slight change to @andy-hook example, hooking into route changes rather than click events - meaning it should catch things like browser fwd/back buttons and keyboard shortcuts etc too
https://codesandbox.io/s/mystifying-germain-mlb900?file=/pages/_app.js
@weskor This should be being handled for you out of the box to be honest so seems like an oversight on our part.
We’ll raise a fix soon but in the meantime you can control the value yourself and set it to an empty string in order to close the menu manually
https://codesandbox.io/s/distracted-gwen-domugj?file=/pages/_app.js
Hope this helps 🙏