I just tried it, and everything seems to work well. How is your app different?
[EDIT] I just noticed that changing dragging modes, from moving to copying or vice-versa, causes the state to be rolled-back, which in this case also hides the triangular shape whose visibility is controlled by the “draggingInProgress” modelData property. So I changed the code so that the setting of “draggingInProgress property is not recorded by the UndoManager. One way of doing that is by explicitly setting skipsUndoManager to true and then to false each time. An easier way is to call commit with a second argument that is null.
<!DOCTYPE html>
<html>
<head>
<title>Minimal GoJS Sample</title>
<!-- Copyright 1998-2025 by Northwoods Software Corporation. -->
</head>
<body>
<div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:400px"></div>
<script src="https://cdn.jsdelivr.net/npm/gojs/release/go-debug.js"></script>
<script id="code">
class CustomDraggingTool extends go.DraggingTool {
constructor(init) {
super();
if (init) Object.assign(this, init);
}
doActivate() {
super.doActivate();
// do any additional setup with skipsUndoManager temporarily true
this.diagram.model.commit(m => m.set(m.modelData, "draggingInProgress", true), null);
}
doDeactivate() {
// do any additional cleanup with skipsUndoManager temporarily true
this.diagram.model.commit(m => m.set(m.modelData, "draggingInProgress", false), null);
super.doDeactivate();
}
}
const myDiagram =
new go.Diagram("myDiagramDiv", {
layout: new go.TreeLayout(),
draggingTool: new CustomDraggingTool(),
"undoManager.isEnabled": true
});
myDiagram.nodeTemplate =
new go.Node("Spot", {
// don't invalidate the layout when nodes change size because node decorations become visible or not
layoutConditions: go.LayoutConditions.Standard & ~go.LayoutConditions.NodeSized
})
.add(
new go.Panel("Auto")
.add(
new go.Shape({ fill: "white" })
.bind("fill", "color"),
new go.TextBlock({ margin: 8 })
.bind("text")
),
new go.Shape("TriangleDown", {
alignment: go.Spot.TopRight, alignmentFocus: go.Spot.TopRight,
width: 8, height: 12, fill: "yellow",
visible: false
})
.bindModel("visible", "draggingInProgress")
);
myDiagram.model = new go.GraphLinksModel({
modelData: { draggingInProgress: false },
nodeDataArray: [
{ key: 1, text: "Alpha", color: "lightblue" },
{ key: 2, text: "Beta", color: "orange" },
{ key: 3, text: "Gamma", color: "lightgreen" },
{ key: 4, text: "Delta", color: "pink" }
],
linkDataArray: [
{ from: 1, to: 2 },
{ from: 1, to: 3 },
{ from: 3, to: 4 }
]
});
</script>
</body>
</html>