Steps to Reproduce
-
Code is given below.
-
Move any node to any position
-
Undo in any way (cmnd + z)
-
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.
