Undo seems to fire a LOT of ChangedEvents?

I’m trying to observe the changes made in an Undo action but it seems like a lot of unexpected events are fired when I undo a change.

For example: I edited the text property of a node, then hit CMD + Z. A text property ChangedEvent fired - great - but there were also a series of additional ChangedEvents for properties such as fill, stroke and isHighlighted. As far as I’m aware, these properties did not change anywhere in my diagram while I was editing a node’s text so I would not have expected to be notified of those property changes when I subsequently used undo.

I am keeping another model in sync with my diagram (we’re using the diagram as an editor UI for an existing data model) so I need to observe any changes made when the user performs undo/redo actions.

So I was wondering why these additional events are dispatched, and how they relate to my earlier text-editing action, and I suppose I’m trying to figure out if there’s an easy way to identify the events that I can safely ignore?

Using v1.8.2

My guess is that those ChangedEvents are from some highlighting changes that happened earlier, outside of a transaction.

When a ChangedEvent happens before a call to startTransaction, it is remembered in a new Transaction anyway. Then when you conduct a transaction that modifies a TextBlock.text, the corresponding ChangedEvent is appended to the already existing Transaction.

Normally for “highlighting” changes one temporarily sets Diagram.skipsUndoManager to true, so that all of the changes related to highlighting are not recorded in the UndoManager. That’s done for you automatically in some circumstances, such as GraphObject | GoJS API, but not for random code that you have executed where we cannot tell the purpose of the change.