Skip to content

Commit

Permalink
fix: Working reset fix [PT-187399412]
Browse files Browse the repository at this point in the history
- On reset the graph is now initially hidden and set to empty, then after a timeout set to the initial graph and redrawn and then shown
- The old graph node x,y is now not updated
- The selected node (if any) is unset
  • Loading branch information
dougmartin committed Oct 3, 2024
1 parent 0ab337d commit 119c47b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -534,16 +534,20 @@ export const App = () => {
setSequenceGroups([]);
setFastSimulation(defaultFastSimulation);
setGraphOpacity(0);
setGraph(initialGraph ? {...initialGraph} : {nodes: [], edges: []});
setSelectedNodeId();
setGraph({nodes: [], edges: []});
setResetViewAt(Date.now());
setTimeout(() => {
if (initialGraph) {
setGraph(initialGraph);
}
setFitViewAt(Date.now());
setGraphOpacity(1);
}, 0);
}, 1);
},
onClose: () => setConfirmModal(undefined)
});
}, [initialGraph, setGraph]);
}, [initialGraph, setGraph, setSelectedNodeId]);

const handleReturnToMainMenu = () => {
setConfirmModal({
Expand Down
9 changes: 6 additions & 3 deletions src/components/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,16 @@ export const Graph = (props: Props) => {
const {minRadius, maxRadius, minStroke, maxStroke} = settings;

graph.nodes.forEach((node, index) => {
const oldD3Node = d3Graph.nodes.find(n => n.id === node.id);
const x = oldD3Node?.x ?? node.x ?? 0;
const y = oldD3Node?.y ?? node.y ?? 0;

const d3Node: D3Node = {
index,
id: node.id,
x: node.x ?? 0,
y: node.y ?? 0,
x,
y,
label: node.label,
// radius: 15 + (5 * (node.label.length - 1)) + (5 * node.value),
radius: minRadius + ((maxRadius - minRadius) * (node.value / totalNodeValue)),
loops: false,
loopWeight: 0,
Expand Down

0 comments on commit 119c47b

Please sign in to comment.