Disable undo manager will cause link changed event not fired?

Hi GoJS group,

I realize if I set undoManager.isEnabled to false in my diagram, I will no longer get go.ChangedEvent.Insert from model changedListener fired? Actually, evt.object is always null. If I mark isEnable to true, everything just works fine. Are they related?

    if (!evt.isTransactionFinished) return;

    let txn = evt.object;  // a Transaction
    if (txn === null) return;

    // iterate over all of the actual ChangedEvents of the Transaction
    txn.changes.each((e) => {
        if (e.change === go.ChangedEvent.Insert) {
            if (e.modelChange === "nodeDataArray") { // add node
            } else if (e.modelChange === "linkDataArray") { // add link


That’s correct – when the UndoManager is disabled, or when Diagram.skipsUndoManager or Model.skipsUndoManager are true, no ChangedEvents are recorded.

1 Like

That makes sense. So if I would like to do more actions when some change happens, I have to enable undo manager.

It would be most commonplace to implement DiagramEvent listeners. But I guess it depends on what it is that you want to watch for.

Actually, I use ChangedEvents in order to capture add/remove/relink/rename happens on diagram, which will cause an update to my model (not gojs model, but other data source). So in this case, do you think what I am doing is right or not?

I see – so listening for Changed events on the Model still makes sense. It’s just that you cannot depend on the UndoManager batching up sets of ChangedEvents in Transactions, because the “Transaction” ChangedEvent raised when a transaction finishes won’t have an actual Transaction with ChangedEvents in it.

Thanks for confirming.

I have another question. How should I know undo/redo happen in ChangedEvent so that I can delete or add corresponded data to my other model as well? Just like I listen on go.ChangedEvent.Insert and I will add something to my other model once I get into this condition. However, undo/redo seams not fire this event. What is the right approach for my purpose?


Yes, it does – that’s what I just mentioned about ChangedEvent.Transaction ChangedEvents, rather than the usual ChangedEvent.Property, ChangedEvent.Insert or ChangedEvent.Remove enum values of ChangedEvent.change.

Thanks for pointing that out. I will have a try.