(Re)linkingTool temporary node style: size being ignored

We have nodes with ports, and the ports are highlighted when their link is selected. As such the temporaryToNode and temporaryFromNode have a style set:

    tempNodeStyle = this.getNodeStyleTemplate();
    linkingTool.temporaryToNode = tempNodeStyle;
    linkingTool.temporaryToPort = tempNodeStyle.port;

getNodeStyleTemplate(): go.Node {
    return this.$(go.Node, {layerName: 'Tool'},
            this.$(go.Shape, 'Circle',
                fill: null,
                portId: '',
                desiredSize: new go.Size(8, 8),
                stroke: 'lime', //this.gojsDiagramStyleProvider.getLinkDuringDrawStyle().stroke,
                strokeWidth: Number(this.gojsDiagramStyleProvider.getLinkDuringDrawStyle().strokeWidth.replace('px', ''))

The stroke change is to prove to myself that I’m looking at the right thing, and works as expected. However, the desiredSize is being ignored. What I am after, is the overlay being the same size as the existing port, but at the moment it seems one pixel larger, and the size seems unalterable.

I actually don’t see the difference in the two screenshots. No matter: the problem is that LinkingBaseTool.copyPortProperties is explicitly changing the temporary port to make it look and act like the actual port. So it is setting the port’s GraphObject.desiredSize as well as toSpot or fromSpot, toEndSegmentLength or fromEndSegmentLength, and angle.

You could override LinkingBaseTool.copyPortProperties to do whatever you like to the tempnode and tempport arguments. Or if you are satisfied with the current behavior except for the size, perhaps easier is providing a LinkingBaseTool.portTargeted function that just sets the desiredSize. That portTargeted function is called at the end of the copyPortProperties and LinkingBaseTool.setNoTargetPortProperties, so it will counteract whatever the default setting of desiredSize. Remember to check that the second argument (the realport) is non-null for when there is no valid port within the LinkingBaseTool.portGravity distance from the mouse.

Apologies, there should have been only one copy of the screenshot.

The portTargeted function fixed the issue.

Given I wanted the temporary port to be the same size and style (except for colour) as the underlying port, I’m a bit confused as to why the copyPortProperties doesn’t just work instead of creating the overlay a bit larger.

Perhaps the issue is whether or not the Shape.strokeWidth is included in the size.