d3-context-menu
d3-context-menu copied to clipboard
Context menu close on mousedown outside of menu doesn't work
I saw the 1.0.1 release note has this Context menu now closes on mousedown outside of the menu, instead of click outside (to mimic behaviour of the native context menu)
. It doesn't work for me. I also made sure the simulation was stopped thinking something might be capturing my click. What could be happening?
When I left click outside nothing happens, when I right click outside it opens the google chrome menu and the context menu dissapears but I'd like to have this working on a left click outside,
Do you have an example? It seems to work for me. I did notice that the plunker on the main page uses an older version of the script, so I tried the version in the repo and it seemed to act correctly.
This is still happening in version 1.1.0. I managed to make an example with this bug that occurs when zoom behaviour is added to the svg.
You can check it in this fiddle https://jsfiddle.net/hqd13mur/5/
Yep, I see it now. It's strange, because if I click to the right or below the menu, it closes, but if I click above and to the left, it doesn't close. If I remove the zoom code, I have no issue.
One fix would be to change line 118 of the source code to this: (or add it below the mousedown code)
d3.select('body').on('click.d3-context-menu', closeMenu);
That seems to fix it for me, does it fix it for you?
Yes! It works like a charm.
Thank you very much for your help.