How to manage single undo/redo for drag-and-drop with custom link handling in GoJS?

Although that should work, it might be clearer to call Model.setKeyForNodeData: Model | GoJS API

Regarding your main question, I thought the problem was that two transactions were happening:

  • The standard one for each drag-and-drop
  • Your asynchronous one that changes the node’s key and splices the new node into the existing link

By avoiding the first one, by cancelling its behavior, you would have a single transaction that would do everything:

  • Insert a new node with the desired key and other properties
  • Modify the existing link to connect to the new node
  • Insert a new link connecting the new node to whatever the old link connected to

This is what many apps do. Your code would then not need to modify the existing node’s key.