Undo shortcut not working

We are finally implementing undo and copy/paste and I changed our code to allow these. Copy/paste works along with other keyboard shortcuts but ctrl-z and alt-backspace don’t do an undo. This is on Window 10 and Chrome. Is there anything else I have to enable for undo shortcuts to work? Here is my code I just changed:

    goDiagram.allowUndo = true;
    goDiagram.allowClipboard = true;

As you can see in the documentation, those Diagram properties are true by default: Diagram | GoJS API

Actually that documentation also shows you how to turn on the diagram’s UndoManager, by setting UndoManager | GoJS API to true.

You can see examples at Get Started with GoJS.

Thanks for the help I got the undo working. Now I need to find a way to be notified when it happens so I can modify data in our app. I’ve tried several things and no luck. I thought this might be the way but it doesn’t work.

    goDiagram.addChangedListener(function (e) {
        me.onChanged(e);
    });

onChanged: function(e) {
    var me = this;
    if (e.propertyName === 'StartingUndo') {
        debugger;
    }
},

Any ideas on how I can listen for undo and redo events and get the node or link that was used?

You’re on the right path, but you need to get events on the Model, not on the Diagram, and then check ChangedEvent.isTransactionFinished. More discussion is at GoJS Changed Events -- Northwoods Software

Slowly making progress on this and I figured out how to get the modified Nodes and Links. The below gets called if I move a node and do ctrl-z. If I delete a node and do ctrl-z it doesn’t get called but the node does return. Shouldn’t both moves and deletes cause a FinishedUndo to happen?

    goDiagram.model.addChangedListener(function (e) {
        me.onChanged(e);
    });

onChanged: function(e) {
    var me = this,
        txn;

    if (!e.isTransactionFinished) {
        return;
    }

    if (e.propertyName === 'FinishedUndo') {
        txn = e.object;
        txn.changes.each(function(change) {
            if (change.object instanceof go.Node) {
                console.log('Node ' + change.object.data.key + ' ' + change.change.toString() + ' ' + change.propertyName);
            }
            else if (change.object instanceof go.Link) {
                console.log('Link ' + change.object.data.key + ' ' + change.change.toString() + ' ' + change.propertyName);
            }
        })
    }
},

Have you seen the Update Demo, Update Demo GoJS Sample ?

Remember that you should be working with changes to the model and data in the model, not with the Diagram nor its Nodes nor its Links, nor with any of the individual GraphObjects in those Nodes or Links.

That means you should only care about those ChangedEvents that have a ChangedEvent.model, not with those that have a ChangedEvent.diagram.