Menu opens whenever I click any link anywhere
See original GitHub issueThere was an issue #91, which unfortunately was promptly closed by the author without providing much explanation. Now I’m hitting the same issue and I have no idea what’s wrong.
const burgerMenu = <Menu
isOpen={isSidebarOpen}
customBurgerIcon={false}
customCrossIcon={false}
>
I open the menu by invoking this:
openMenu = () => {
this.setState({
isSidebarOpen: true,
});
}
and rely on clicking on overlay for closing it.
The problem is every time I click on a link anywhere it triggers opening the menu. Has anyone seen this behaviour?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Whenever I click on any link or sometimes just a ... - Quora
If you're using Google Chrome: launch the browser → press 3 dots on the top right corner → Settings → Privacy and Security...
Read more >get menus popping up every time I click o… - Apple Community
Today I was working with an online grocery store and suddenly, no matter where I clicked, a menu would open listing various options....
Read more >The menu opens / closes when I click anywhere on the page
I want to link the isOpen={ toggleMenu } to a custom button with an onClick and have that be the only way to...
Read more >How to stop Chrome from opening new tabs for every link
In the drop-down menu, just click on Search settings. On the following page, scroll down towards the bottom to the 'Where results open'...
Read more >Every time I click a link to open it, it makes a new tab. How do I ...
Go to Chrome Settings . . . Advanced . . . (or you can enter chrome://settings/reset into the omnibox as a direct way...
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
@t-sean Indeed! Thanks a lot for your suggestion; this solves my issue. Basically, I needed
onStateChange
to update my internal state after clicking on the overlay. If I don’t do that then the state remainsopen
. In this case, clicking theLink
triggerscomponentWillReceiveProps
on theMenu
, and sinceisOpen
is wrong at this point, theMenu
shows up.I saw something similar while handling my own isOpen state. Clicking out of overlay, or pressing escape would change the internal state of burger-menu, but obviously not update my own isOpen state. So if i closed the menu one of those ways, my state was still set to open, and a re-render from prop changes would cause the state check to open the menu.
This would also cause what seemed like having to double click my open/close icon, the first click updating my open state to false, then the setting it to open.
Adding the onStateChange handler to my app kept them both in synch.