Hi,
We’re working on a GoJS diagram where we have interactive elements like context menus, add node buttons, etc. During keyboard navigation, when a user focuses on one of these external elements (like opening a context menu or triggering an add node button), a dialog/modal is opened for additional actions.
Once the user finishes the operation and the dialog/modal is closed, we want to programmatically restore the focus to the last accessed diagram element — be it a node or a link — that the user interacted with before the modal opened.
Is there a recommended way in GoJS to track and programmatically set focus back to the previously focused node or link after closing a modal?
I tried using the lostFocus
and regainFocus
events. The lostFocus
event gets triggered when the modal opens, but regainFocus
doesn’t fire after the modal is closed.
I know that calling this.diagram.focus()
can help, but the modal is triggered from an external component that’s not under our control. Is there a way to handle this scenario and properly regain focus back to the diagram?