Node move does sometimes not move the links

Using 1.6.18.
Added a clipboard handler to move the copied nodes on the mouse position. However, sometimes the links are not moved.

diagram.addDiagramListener("ClipboardPasted", clipboardPasted);

 function clipboardPasted(e) {

                      var firstSelection = diagram.selection.first();
                      if (!firstSelection) return;

                      var mouseLocation = diagram.lastInput.documentPoint;
                      var displaceX = mouseLocation.x - firstSelection.location.x + firstSelection.actualBounds.width / 2;
                      var displaceY = mouseLocation.y - firstSelection.location.y + firstSelection.actualBounds.height / 2;


                      diagram.selection.each(function (current) {
                          if (current instanceof go.Link) return; // skips over go.Link
                          current.move(new go.Point(displaceX + current.location.x - current.actualBounds.width / 2, displaceY + current.location.y - current.actualBounds.height / 2));


See picture: CTRL-A, moved mouse, press background, CTRL-V. The nodes are perfectly positioned, the links are still highlighted on the original links.

See picture: Using the move keys to move the selected nodes to make it better visible.

Moving the nodes with the mouse, paints the links correct.

I am also using the centerX and centerY from DrawCommandHandler, which behaves correct. Any idea, why my links are not moved with the above (similar) code?

Was there a reason that you explicitly skipped moving the Links as well as the Nodes?

You’ll note that the extensions/DrawCommandHandler.js code just calls Diagram.moveParts to shift a bunch of nodes and links.

Was there a reason that you explicitly skipped moving the Links as well as the Nodes?

Skipping only the links:
if (current instanceof go.Link) return;
As like all align methods in DrawCommandHandler.

Changed the above code to use:
diagram.moveParts(diagram.selection, new go.Point(displaceX, displaceY));

Now everything works fine. Thx for the hint.

Still unclear why my original code sometimes misbehaved and the align functions work flawless. Any idea (don’t want to abuse your valuable time)?

Well, say you have two nodes connected by a link. If you want the nodes to be aligned in some fashion, you wouldn’t want the links to be moved, would you? No, the links should be routed normally, depending only on the Nodes’ new positions.

But if you are making a copy of a graph of Nodes and Links and want to shift them, you better shift them all.