Odd behavior of Undo/Redo mechanism

I’ve prepared a sample for the problem that I want to describe.

Above example shows that undo/redo works fine in case of data itself so I have the same result as I had before,
but in case of “real” nodes it’s not. Everything looks good when I call diagram.updateAllTargetsBindings();.

I don’t know how it should behave (which data are correct those in a real node or in data), but I definitely those two should stay in sync.

Thank you in advance

If you set Diagram.skipsUndoManager to true (which also sets Model.skipsUndoManager), then the UndoManager will not be recording any ChangedEvents.

That JSBin first conducts a transaction to add a node. Second it temporarily turns off skipsUndoManager when modifying a data property of that new node. Third it does an undo; fourth it does a redo.

But if you add the statement:

console.log(diagram.undoManager.history.length);

at the end of the second setTimeout, you will see that the value is 1 even though there have been two changes made.

So the undo removes the node from the diagram. It does not restore the old value of the data.text property while keeping the node in the model and diagram.

By the way, you ought to be calling startTransaction and commitTransaction around the change(s) made in the second step. However in this case that would not affect the behavior. Temporarily turning off skipsUndoManager means there’s no second transaction to be undone.