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;
}