NorthwoodsSoftware / GoJS

JavaScript diagramming library for interactive flowcharts, org charts, design tools, planning tools, visual languages.
http://gojs.net
Other
7.7k stars 2.86k forks source link

updateTargetBindings causing empty transactions in undoManager #175

Closed lukeheckman closed 2 years ago

lukeheckman commented 2 years ago

updateTargetBindings adds an empty step in the undoManager with an empty transaction name. Undoing or redoing will result in an extra step as well where no visual changes occur (e.g. Having to undo three times instead of two to revert a model's relinking steps).

image

To fix this, I implemented a workaround using skipsUndoManager whenever calling updateTargetBindings to reach the intended behavior.

WalterNorthwoods commented 2 years ago

The operation of updateTargetBindings does not conduct a transaction. It is just a way of evaluating some bindings.

Did you call updateTargetBindings within a transaction and without making any other changes to model or diagram that got recorded in the UndoManager? You could do something like myDiagram.commit(diag => {...}, null) or myDiagram.model.commit(mod => {...}, null) if you want to commit a transaction that skips recording in the UndoManager. The second argument of null tells it to perform the whole transaction with skipsUndoManager set to false.