Invalidate link routes while moving a node

Hi, I’m using genogram code from the example here: Genogram
I defined my own link type, it’s points are affected by the sibling links.

  myDiagram.linkTemplate = // for parent-child relationships
    $(
      CustomLink(),
      {
        routing: go.Link.Orthogonal,
        corner: 5,
        layerName: "Background",
        selectable: false,
      },
      $(go.Shape, { stroke: "#424242", strokeWidth: 2 })
    );

  function CustomLink() {
    class CustomLink extends go.Link {
      public computePoints(): boolean {
        const result = go.Link.prototype.computePoints.call(this);
        const pts = this.points;
        const parents = this.fromNode;
        let childrenCount = 0;
        let sumX = 0;
        parents?.findNodesOutOf().each((child) => {
          childrenCount++;
          sumX += child.location.x;
        });
        const posX = sumX / childrenCount;
        const posY = pts.elt(0).y + 57;
        pts.setElt(2, new go.Point(pts.elt(0).x, posY));
        pts.setElt(3, new go.Point(posX, posY));
        pts.setElt(4, pts.elt(5));
        return result;
      }
    }
    return CustomLink;
  }

I’m using ChangedListener to invalidate the sibling links when a link is being moved, however this ends up in an infinite loop of invalidating links and recomputing points. How can I prevent the infinite loop? Is it possible to pass arguments from invalidateRoute all the way to computePoints so I can prevent it?

    myDiagram.addChangedListener((e) => {
      if (e.propertyName !== "points") return;
      if (!(e.object instanceof go.Link)) return;
      const link = e.object;
      const siblingLinks = link.fromNode?.findTreeChildrenLinks();
      siblingLinks?.each((l) => {
        if (l !== e.object) l.invalidateRoute();
      });
    });

Yes, I can see that that strategy isn’t going to work.

Why don’t you have the DraggingTool invalidate the route of links connected with the parent node? You can either do that at the end of the drag by implementing a “SelectionMoved” DiagramEvent listener to invalidate some link routes, or you could override DraggingTool.moveParts to call the super method and then invalidate some link routes.

Overriding DraggingTool.moveParts solved it. Thank you.