About the movement of the node after executing Ctrl + Z

e1552da10993243b350d59b56e0820fb

When I execute “Ctrl + Z,” the child nodes should disappear, but when I press “Ctrl + Z” three times, the child nodes disappear. The issue may be related to the visible code in the TreeExpanderButton , but I’m not sure what needs to be modified. Here’s the code you provided:

function createNodeTemplate(self) {
  return $(
    go.Node,
    'Spot',
    {
      cursor: 'move',
      locationSpot: go.Spot.Left,
      selectionObjectName: 'NODE',
      layoutConditions: go.Part.LayoutStandard & ~go.Part.LayoutNodeSized,
      selectionChanged: (obj) => nodeSelectionChanged(self, obj),
      mouseHover: (_e, obj) => nodeMouseHover(self, obj),
      mouseLeave: (_e, obj) => nodeMouseLeave(self, obj),
      selectionAdornmentTemplate: $(
        go.Adornment,
        'Spot',
        $(go.Panel, 'Auto', $(go.Placeholder)),
      ),
      contextMenu: $(go.HTMLInfo, {
        show: self.showNodeContextMenu,
        hide: self.hideNodeContextMenu,
      }),
    },
    // ...
    $(
      go.Panel,
      'Auto',
      { name: 'NODE' },
      $(
        go.Shape,
        'Rectangle',
        {
          fill: 'white',
          strokeDashArray: [],
          name: 'RECTANGLE',
        },
        // ..
      ),
      $(
        'TreeExpanderButton',
        { name: 'NodeTreeExpanderBtn' },
        {
          alignment: go.Spot.Right,
          'ButtonIcon.strokeWidth': 0,
          'ButtonBorder.figure': 'Circle',
          'ButtonIcon.visible': false,
          // ..
        },
        new go.Binding('visible', '', (obj) => {
          return !(obj.isTreeLeaf || parentNodeTreeExpanded(obj))
        }).ofObject(),
      ),
    )
    // ...
  );
}

const parentNodeTreeExpanded = (obj) => {
  return obj.isTreeExpanded and !obj.isTreeLeaf;
}

That’s not code that we provided.

What had the user done just before invoking Undo three times?