Prevent link from changing from or to port when moving nodes

Hello,

I would like to know how to prevent links from changing ports when dropping from a palette or when the nodes are moved (the software chooses the shortest path).

For instance, in this example : Link Shifting Tool links change ports when nodes are moved.

Hoever, in this example : Snap Link Reshaping links don’t change ports when nodes are moved.

Thank you for your help

Moving a node does not change the port that any link connects with. If a spot has not been specified either at the port or on the link itself, the connection point will be the closest intersection of the link with the edge of the port. Please read GoJS Link Connection Points on Nodes -- Northwoods Software

I have just realised that in my diagram when linking for the first time, the software takes the shortest path between two spots (and does not keep the assigned from and to spot) but when relinking, the software does keep the assigned from and to spot as I want to. Do you know what could be the reason? Thank you

Something must be setting the fromSpot and/or toSpot.
Note how in the LinkShiftingTool extension, when the tool succeeds it sets one of those properties on the Link whose end was shifted. The idea is that it should remember what the user specified.

Note that it is also commonplace for a layout to assign link spots. But that only happens if you have assigned Diagram.layout to an instance of an oriented layout class.

I have an example here : weathered-smoke-bn8ic - CodeSandbox

If you create two nodes from the palette and link the two, the fromspot and tospot won’t be the one assigned. However, you can relink to the spot I want. There is no layout.

Your initDiagram function needs to modify the Diagram.model so that it supports ports, by setting GraphLinksModel.linkFromPortIdProperty and linkToPortIdProperty to the property names on the link data objects that you want to remember the port identifiers.

https://gojs.net/latest/intro/ports.html#GeneralPorts