After hiding nodes links stay visible

When I make the nodes in the diagram hidden i.e. set node.visible to false.

The links for the hidden nodes still show up in the diagram and relink themselves to the node(s) that is(are) visible!

Is there some flag or something that I am missing?
I don’t understand why the links are staying visible?!

I can explicitly hide them but it’s a pain and I know from reading other answers in this forum that this is not supposed to be necessary.

I use this method to hide the nodes:

vm.diagram.commit(function(diag) {
  diag.nodes.each(function(node) {
            node.visible = true

            if ( someConditional ) 
              node.visible = false
          })

        }, 'toggle visibility')

The problem is that this leaves the links visible in the diagram.

There is a lot of code to my template but this is the gist of the layout and nodes:

let groupTemplate = $(
    go.Group,
    'Vertical',
    {
      layout: $(go.LayeredDigraphLayout, { direction: 0, columnSpacing: 10 }),
      movable: false,
    },
    $(
      go.TextBlock, // group title
      { alignment: go.Spot.Left, font: 'bold 25px Barlow', stroke: '#1B405F' },
      new go.Binding('text', 'title')
    ),
    $(
      // For spacing the title from the rest of the nodes
      go.Shape, {
        fill: 'transparent',
        strokeWidth: 0,
        height: 10,
      }),
    $( go.Panel, 'Auto',
      $(
        go.Shape, {
          fill: 'transparent',
          strokeWidth: 0,
        }),
      $(go.Placeholder, { background: 'transparent' })
    )
  )

The nodes template

  let blockTemplate = $(
    go.Node,
    'Auto',
    {
      toSpot: go.Spot.Right,
      fromSpot: go.Spot.Right,
      stretch: go.GraphObject.Horizontal,
      isShadowed: true,
      shadowColor: 'rgba(36,78,113,0.4)',
      shadowOffset: new go.Point(-1, 1),
    },

    $(go.Shape, { fill: 'white', stroke: null, name: 'block'}),

  $(
    go.Panel,
    'Table',
    {
    width: 230,
    padding: 2,
    defaultStretch: go.GraphObject.Horizontal,
    defaultAlignment: go.Spot.Center,
    margin: 10,
  },

    $(go.Picture, {
        name: 'Picture',
        width: 35,
        height: 35,
        row: 0,
        rowSpan: 2,
        column: 0,
        margin: new go.Margin(0, 10),
      },
      new go.Binding('source', 'icon'),
      new go.Binding('visible', hasIcon)
    ),

    $( go.TextBlock, {
        row: 0,
        column: 1,
        font: 'bold 18px Barlow',
        stroke: '#497A98',
        wrap: go.TextBlock.None,
        margin: new go.Margin(10, 0),
      },
      new go.Binding('text', labelProp)
    ),

    $( go.TextBlock, {
        row: 1,
        column: 1,
        font: '16px Barlow',
        stroke: '#497A98',
        wrap: go.TextBlock.None,
        overflow: go.TextBlock.OverflowEllipsis,
      },
      new go.Binding('text', '', node => (node.vendor ? node.vendor : ''))
    )
  )
  )

link template:

$( go.Link,
    {
      corner: 1,
      selectable: false,
      fromEndSegmentLength: 0,
      toEndSegmentLength: 0,
      routing: go.Link.Normal,
    },

    $(go.Shape, {
      stroke: '#B7CBD6',
      strokeWidth: 1,
      opacity: 1,
    }),
    $(go.Shape, { toArrow: 'Triangle', scale: 1, fill: '#B7CBD6', stroke: 'transparent' }),
)

My layout is as follows:

let treeLayerOptions = {
    alignment: go.TreeLayout.AlignmentStart,
    setsPortSpot: false,
    setsChildPortSpot: false,
    layerSpacing: 300,
    isOngoing: false,
  }

  const layout = $(go.TreeLayout, treeLayerOptions)

  let options = {
    layout,
    allowDelete: false,
    allowCopy: false,
    scrollMode: go.Diagram.InfiniteScroll,
    maxSelectionCount: 1,
    'toolManager.mouseWheelBehavior': go.ToolManager.WheelZoom,
    'animationManager.isInitial': false,
    'draggingTool.gridSnapCellSize': new go.Size(50, 50),
    'draggingTool.isGridSnapEnabled': true,
    'draggingTool.isEnabled': false,
  }

The default policy is that when a link that is connected with a node that is a member of a visible group (and is not also a member of the group) and that node becomes not-visible, the link is routed to connect with the group. In our experience, this is what is most frequently desired. Normally this happens when a group is collapsed.

But what you want is a perfectly reasonable alternative policy. One of several alternatives, actually. I believe there is a relatively easy way to get that by customizing a class. That’s something I could look into.

I see, in that case I will also go through the links and make them hidden.

It might be worth to note this in the docs somewhere.
I spent a lot of time trying to understand if this was a bug from gojs or on my side.
Apparently this is a classic feature not bug case.