I am calling canUndo() to find out when there is no more transactions to undo. Before there were any changes made in the diagram the value returned is false. Once an transaction is done the value returned is true and stays true no matter how many times I call the function commandHandler.undo().
I see that all the changes were undone also in the diagram and canUndo() was still true. I tried using both undoManager.canUndo() and commandHandler.canUndo() with the same result.
goMake(
go.Node,
go.Panel.Spot,
{
name: 'undo-template',
locationSpot: go.Spot.Center,
resizable: false,
selectionAdorned: false,
cursor: 'pointer',
mouseEnter: (_e: go.InputEvent, obj: go.Part) => {
},
mouseLeave: (_e: go.InputEvent, obj: go.Part) => {
},
click: (_e: go.InputEvent, obj: go.Part) => {
mainDiagram.commandHandler.undo();
if(!mainDiagram.commandHandler.canUndo()){//This line is always false because canUndo() is always true
//change icon
}
},
},
goMake(go.Picture, {
name: 'undo-icon',
...
}),
goMake(go.Shape, goObjectTypes.Rectangle, {
name: 'backgroundShape',
...
}),
);