Have to click twice to show customized context menu

I currently run into an issue that I have to click twice in order to show my customized html context menu. The html context menu is hosted under a div. So I just change div’s style, i.e. display, top, left.

I have read this post How to bring up HTML context menu immediately upon click, and my symptom is very similar to this one.

With a context menu opening, if clicking on some other point, only hideContextMenu will be called. I have to click again in order to trigger showContextMenu. However, if I keep clicking on the same position, the showContextMenu will be trigerred each single click.

Any idea? Thanks in advance.


I cannot reproduce that behavior at http://gojs.net/latest/samples/customContextMenu.html. In other words, I have no problems context-clicking on a node and then context-clicking on another node – the second node is selected and the HTML context menu shows immediately for the second node.

However I do notice an error when trying to change colors – we’ll fix that for the next release.

Actually, I am trying to click on same node but on different position. Only reclick on same point will invoke context menu immediately. I agree with that the sample working fine. But can you tell what is the possible reason that second click on different point of same node won’t trigger showContextMenu but only hideContextMenu? I even try to listen blur event but it doesn’t help.

Yes, I find that context-clicking on a node and then again anywhere on the same node just moves the visible context menu. That is what you want, yes?

I think you’ll have to debug your code to see why your code to hide your context menu is being called.

Yes, that is exactly what I want. I think I do the very similar thing as what example does. I will keep investigating and reply if any found. Thanks anyway

Actually, my context menu is not html one as shown in example. I am using jquery style. That is to say, I create a dummy div for right click on it to open the context menu. The div itself is not the context menu but the host of right-click menu. The example shows me how to enable or disable a html div basically. However, how can I make it work further to trigger contextmenu on right click this div? Thanks.

I have no idea – that’s up to how jQuery manages context menus, so I would search jQuery’s documentation.