Diagram loses focus after custom context menu closure

Hello!

I am having an issue with a custom gojs context menu. To remain consistency throughout my application (that uses a lot of Syncfusion components), I also tried to use the Syncfusion context menu for the gojs diagram and therefore wrapped it in a go.HTMLInfo element.

But when I did this, I recognized that after using the context menu, I lose the focus on the diagram for the first click. When I click once, it regains focus, so that the second click will be registered again.

I prepared a stackblitz to demonstrate that behaviour: Angular GoJs (forked) - StackBlitz

To repdroduce the problem, right click the diagram to open the custom context menu, click on “test” and then try to select the node. On the first click, it will not be selected, but only on the second.

I tried to use the go.Diagram.focus()-method on the context menu close event, but that did not help either.

Do you have any ideas, how to fix this? Is there any other possibility to regain the focus of the diagram?

Thanks in advance
Jonas

That problem does not happen in the basic custom context menu we have here: HTML Context Menu

This suggests that some part of your system, I assume the Syncfusion menu but it may be something else, is capturing the event and not bubbling it or is stopping propagation in some way. Unfortunately I don’t know enough about Syncfusion to say what you should try.

If that does not work, and you have have access to the click (well, pointerup hopefully) event itself, you may want to try dispatching it, or creating a new event and dispatch onto the Diagram’s canvas (Diagram.div.firstChild). But this should only be attempted if there’s no option to bubble/propagate the event that Syncfusion seems to be capturing.

If you change this.myDiagram.focus() to this.myDiagram.currentTool.stopTool(), does it behave as you expect?

The reasoning for this is that the ContextMenuTool is still running when coming back from your custom menu. This is why the HTML Context Menu that Simon posted calls stopTool in its cxcommand function.

Thank you guys for your answers. What jhardy wrote is indeed the solution. The Syncfusion ContextMenu does not seem to end the context menu tool. Doing that manually restores the expected behaviour!