Hello,
we have stumbled upon an issue with relinking links between different nodes.
As example. we have 2 nodes with 3 output ports each. Those ports have the same portIds. “1”, “2” and “3”.
Example nodes:
[
{id: 1, label: A, ports: [{label: “A1”, id: “1”},{label: “A2”, id: “2”},{label: “A3”, id: “3”}]},
{id: 2, label: B, ports: [{label: “B1”, id: “1”},{label: “B2”, id: “2”},{label: “B3”, id: “3”}]}
]
The ports are represented in the diagram in their respective template as textBlocks. In the template, we assign a custom function to the linkConnected
callback. This function has 3 arguments, which should be:
thisNode
: the new node the link got connected to.
newLink
: the new link that got connected.
thisPort
: the port that got connected to.
When relinking a link from node1 port1 to node1 port2, this callback does not get executed at all. Which is quite cumbersome because we now have to manually listen to the diagram LinkRelinked
event and execute our similar code there. Why is there no LinkRelinked callback on the node or something similar?
When relinking a link from node1 port1 to node2 port3, the newLink
and thisPort
arguments inside the callback are wrong.
While debugging this issue, we found what we assume is the cause of this behaviour.
reconnectLink
executes and sets t
(the link) fromNode
which then causes the setter to execute our callback LinkConnected
before fromPort
or its portId
was changed. Resulting in a wrong link and port.
So instead of getting node2 port3, you get node2 port1, because the portId
of the old port is matched on the newNode, instead of the port with the new portId
.
We assume this is a problem (bug) with the program execution timeline.