Copy/paste, "addNodeData" are not triggering "avoidsNodes" links to reroute

Hello!

From what I saw, it seems that rerouting of “avoidsNodes” links are not triggered by adding nodes neither by copy/pasting, nor by “addNodeData”, maybe because it’s what it’s using under the hood.
Are there any workarounds or maybe possible future fixes for that?
When node exists on canvas and I directly move it onto the link everything is fine.

Yes, that’s true. The DraggingTool calls Diagram.moveParts, which does check for needing to call Link.invalidateRoute on each Link that passes through the areas where the Nodes have been moved to.

Other tools don’t do the kind of check that you are talking about, such as the ResizingTool.

Hmmm, I suppose the Paste command should re-route Links going through where it’s pasted. But because often the pasted nodes need to be moved anyway, I’m not sure re-routing the Links where they were pasted makes sense.

@walter okay, I got it, thanks.
But with “addNodeData” it kinda creates problems and the only solution for now is to either check nearest parts and update them, or jiggle the node after adding.

Yes, after you call Model.addNodeData you could call Diagram.findNodeForData or Diagram.findNodeForKey for each node data that you have added, and then call Diagram.moveParts. That’s also useful if you want to align the nodes to a grid.

1 Like