d3-context-menu icon indicating copy to clipboard operation
d3-context-menu copied to clipboard

Context menu close on mousedown outside of menu doesn't work

Open newtoniumx3 opened this issue 6 years ago • 4 comments

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,

newtoniumx3 avatar Oct 06 '18 23:10 newtoniumx3

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.

patorjk avatar Oct 09 '18 21:10 patorjk

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/

daniboygg avatar May 16 '19 11:05 daniboygg

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?

patorjk avatar May 16 '19 13:05 patorjk

Yes! It works like a charm.

Thank you very much for your help.

daniboygg avatar May 16 '19 15:05 daniboygg