Including another transaction in "ExternalCopy" transaction created by a drag and drop action

I have a diagram that I am dragging elements into from another diagram. (Actually creating a copy of the element in the target diagram.) This drag and drop action is creating a transaction named “ExternalCopy”. On the event of “ExternalObjectsDropped” I am also doing another transaction using startTransaction and commitTransaction functions. When undoing or redoing using undoManager, these two transactions are separate but I want them to be one transaction. Is there a way to do this?

As documented, GoJS Events -- Northwoods Software, everything performed within such a listener is executed within a transaction conducted by the DraggingTool.

So you don’t have to conduct your own transaction, but if you do it will be a piece of the overall transaction. An undo will undo both the drop and whatever you do in the listener(s).

I see that in other cases it works as you stated. In this specific case the user is dragging and dropping an element creating a copy of the element in the target diagram. Then on event of “ExternalObjectsDropped” there is a dialog popup where the user can choose what name to give the element and then a second node is created with the name the user gave replaces the node that was dropped into the diagram. When I check the history of the undo manager I see two separate transactions, “External Copy” and a transaction that happens when the new node is created. What can be causing this? Is there a way to have both transactions merged into one?

Well, it seems natural that there be two separate transactions, corresponding to the two separate events: the drop and the completion of the dialog. Just as with database systems, there should not be an indefinitely long transaction covering both events.

The API doesn’t support the merging of two transactions, but I suppose that could be done. Maybe it would be easier to just undo that “External Copy” transaction and then perform a transaction including everything that you want.