negomi/react-burger-menu

Clicking on menu item does not close the menu

Closed this issue · 4 comments

I didn't find anything in the documentation, I may missed it.
When menu is open and user clicks on the navigation item, the menu should close, how to achieve that?

Just add a onClick={() => ctx.toggleMenu()} or whatever the function is you use to open / close the menu to each link elem in your menu.

@pinkpigeonltd How do you close the menu programmatically ?

The inbuilt toggleMenu function does that. The menu provides a context (here, ctx), so ctx.toggleMenu() is the function you need to call to close the menu from anywhere that the context is provided. (Make sure to wrap any part of your app that needs this context, in the context provider. Also ensure that you then import the context. Then you can call the function to close the menu)

stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.