I’m doing some changes to nodeDataArray in some special use case when handling “ExternalObjectsDropped” event.
Those changes are: adding newNode to the model, adding one extra link, and updating some props of existing node in model. All of that happens within my transaction.
Now I’m having issues with scenario if I use undo right after this event happens.
I’m overriding diagram.commandHandler.undo and
I expect to see my transaction as diagram.undoManager.transactionToUndo or at diagram.undoManager.history as last one, but actually it is missing form history and last transaction in the history list is “ExternalCopy”.
Please assist me with handling my transaction correctly for undo action.
Thanks a lot for a code example! It really helps me to figure out what was wrong with my code.
Long story short - I’ve set a custom prop to node.data just by assigning value
like this: node.data.customProp = value;
Even though it happens inside of commit transaction, apparently that wasn’t enough to perform undo correctly (with all necessary reversal).
That lead me to wrong idea, to handle what I need in undo override. Now everything works perfectly as expected. Now I’m using model.set() to assign value, and that solves all the issue so far.
Thanks @jhardy for assist!