From fd3161b767ff60214208279966208a5ae0bd9eb8 Mon Sep 17 00:00:00 2001 From: Doug Martin Date: Wed, 3 Apr 2024 06:13:02 -0400 Subject: [PATCH] fix: Moving a state node should not trigger a re-layout [PT-187321170] --- src/components/graph.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/graph.tsx b/src/components/graph.tsx index a875ed6..8b01366 100644 --- a/src/components/graph.tsx +++ b/src/components/graph.tsx @@ -546,11 +546,17 @@ export const Graph = (props: Props) => { while (simulation.alpha() > simulation.alphaMin()) { simulation.tick(); } + + // pin the nodes so that dragging does not cause a force layout change + d3Graph.nodes + .forEach((d: any) => { + d.fx = d.x; + d.fy = d.y; + }); } // calculate the edge positions d3Graph.edges = calculateEdges(d3Graph.edges); - // d3Graph.nodes = calculateLoops(d3Graph); const lineBackgroundClass = [ "edge-background",