Invalidating route in any possible way breaks links routing after "undo" was executed

Steps to Reproduce

  1. Code is given below.

  2. Move any node to any position

  3. Undo in any way (cmnd + z)

  4. Select link and invalidate it (invalidateRoute/updateRoute/set link points to , etc)


Expected Behavior

Link is connected to the correct point - where node actually is

Actual Behavior

Link is connected to the point where node was before “undo”

\

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>GoJS Simple Diagram with Undo</title>
    <script src="https://unpkg.com/gojs/release/go.js"></script>
    <style>
        html, body {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: sans-serif;
        }
        #myDiagramDiv {
            width: 100%;
            height: 100%;
            border: 1px solid #aaa;
        }
    </style>
</head>
<body>
<div id="myDiagramDiv"></div>

<script>
    function init() {
        const $ = go.GraphObject.make;

        const myDiagram = $(go.Diagram, "myDiagramDiv", {
            "undoManager.isEnabled": true
        });

        myDiagram.nodeTemplate =
            $(go.Node, "Auto",
                {fromSpot: go.Spot.AllSides, toSpot: go.Spot.AllSides},
                $(go.Shape, "RoundedRectangle",
                    { strokeWidth: 0, fill: "lightblue" }),
                $(go.TextBlock,
                    { margin: 8, editable: false },
                    new go.Binding("text", "key"))
            );

        myDiagram.linkTemplate =
            $(go.Link,
                { routing: go.Link.Normal, curve: go.Link.None, fromSpot: go.Spot.Default, toSpot: go.Spot.Default},
                $(go.Shape),
                $(go.Shape, { toArrow: "Standard" })
            );

        myDiagram.model = new go.GraphLinksModel(
            [
                { key: "Node 1" },
                { key: "Node 2" }
            ],
            [
                { from: "Node 1", to: "Node 2" }
            ]
        );

        myDiagram.startTransaction("move node");
        const node1 = myDiagram.findNodeForKey("Node 1");
        if (node1) node1.location = new go.Point(-150, 0);
        myDiagram.commitTransaction("move node");
    }

    window.addEventListener("DOMContentLoaded", init);
</script>
</body>
</html>

Copy for issue on github:

It would be good to know possible workaround, as in my scenario I need to reset “adjusting” and link points.

Thanks for providing code and instructions. I can reproduce the problem and we’re looking into it.

1 Like

This should be fixed in v3.1.1, which we should be releasing soon, assuming no continuing problems with Cloudflare.

Both 3.1.1 and 3.0.28 are now available on npm and our web site.

1 Like