Unexpected node position in LayeredDigraphLayout

Hi folks,

I’ve built a diagram where some nodes are linked together and nested within groups. I’m running into an unexpected result with my diagram layout when I hide nodes/groups. My diagram starts off like this:

and when I hide the nodes and group on the right side by setting their visible flag to false, it looks like this:

Notice how the node in the bottom right is oddly far away from the rest of the diagram. That’s what I’m struggling to understand. If I render the diagram from scratch, this isn’t a problem.

Possibly relevant: the code that updates the diagram:

function updateDiagram(nodes, links) {
  diagram.model.commit((m) => {
    m.mergeNodeDataArray(nodes);
    if (m instanceof go.GraphLinksModel) {
      m.mergeLinkDataArray(links);
    }
  });
}

The nodes are hidden using the binding below:

function visibleBinding () {
  return new go.Binding("visible", "hidden", (hidden) => !hidden);
}

Code sample here - use the buttons in the bottom left to reproduce the issue
GoJS version: 2.1

Thank you!

We’ll look into this later today.

I cannot explain that behavior, which seems to depend on a particular combination of LayeredDigraphLayout properties and Link properties.

But if you are willing to upgrade to v2.3 and set the new property LayeredDigraphLayout.alignOption to go.LayeredDigraphLayout.AlignAll, the problem does not occur. Try setting it in your CodePen, along with:

<script src="https://unpkg.com/gojs"></script>

Thank you @walter, that indeed fixed the problem. I appreciate your help.