selectionChanged event and skipUndoManager


I know there has been this topic a few time before. But I still can’t find out, why is my skipUndoManager not working properly. I’ve implemented a changedSelection event on my Node to call this function:

function onSelectionChanged(node) {
      diagram.skipsUndoManager = true;
      let textBlock = node.findObject('textBlock');
      let roundedRectangle = node.findObject('roundedRectangle');
      let rectangle = node.findObject('rectangle');
      let panelAddUser = node.findObject('panel-add-user');
      if (node.isSelected) {
        roundedRectangle.fill =;
        roundedRectangle.strokeWidth = 4;
        textBlock.stroke = 'white';
        rectangle.alignment =  new go.Spot(0.5, 1.4);
        panelAddUser.alignment = new go.Spot(0.5, 1.8);
      } else {
        roundedRectangle.fill = colorSetOpacity25(;
        roundedRectangle.strokeWidth = 0;
        textBlock.stroke =;
        rectangle.alignment =  new go.Spot(0.5, 1.42);
        panelAddUser.alignment = new go.Spot(0.5, 2);
      diagram.skipsUndoManager = false;

But It seems that transaction is still performing. When I comment this piece of code, undoManager works just fine.

Thanks for any advice!

My guess is that the changes you are making to that Node are causing side-effects within the transaction. In particular, changing the size of the node is likely to invalidate the layout, causing it to be performed and thus making changes to the diagram (and maybe model). Read about this at

That’s one of the advantages of using Adornments – the adorned Part is completely unaffected. And Adornments are never recorded in the UndoManager.

I’m a bit confused …
You say, there is a layout system, which works with nodes/links?
So, there is a minor bug in my project (editor), due to this system.
Could you be more specific, please?

Let’s say I have Node:
I click on it:
Change it’s color:
Click on my Undo button:
Click on my Redo button:

If you are not confused, as I am, could you tell, where the problem is buried?

I’m grateful for any advice!

Note that says that the function is called with Diagram.skipsUndoManager already set to true for the duration of the call. And that you do not need to start and commit any transaction.

1 Like

Yes, I read about those.

May I call a function whanever is commandManager.undo() or commandManager.redo() invoked?

Are you asking about making changes to the diagram or model when the user performs an Undo or a Redo command? No, that would be a bad idea unless you are very careful.

I found out how to call function when commandHandler.undo/redo is invoked in an DiagramEvent, now I’m strugled how to call all Nodes in diagram, in that DiagramEvent (I don’t mean nodeDataArray, but Nodes for which I can call findObject() function). Hope will found out this one soon.
Thanks for your help @walter!