Link set on different port on category change

Hi Team,
We are facing some issues while updating the link category.
We are having two link categories, with no difference between them (Both link category are kept same to reproduce the issue with minimal changes, later we will modify one of the template)
The graph initially is below

When changing the link category using setCategoryForLinkData(), we get below.

And this is the link template data

const $ = go.GraphObject.make;
    return $(
        routing: go.Link.AvoidsNodes,
        curve: go.Link.JumpOver,
        corner: 10,
        toShortLength: 7,
      $(go.Shape, new go.Binding("stroke", "color")),
          toArrow: "Triangle",
          fill: "gray",
          stroke: null,
        new go.Binding("fill", "color")

When toShortLength property is not set, we don’t see the issue.
Please, have a look at this issue.

What is probably happening is that your layout has set the Link.fromSpot and Link.toSpot on each of the Link instances. When you then change the category/template, the new Links (i.e. copies of the other template) do not have those values for fromSpot and toSpot, thus resulting in different routing.

Do one of the following:

  • preserve the spots in the link data, or
  • copy them to the new instances yourself, or
  • perform another layout, or
  • preassign the spots in both link templates.