Skip to content

Commit

Permalink
Merge pull request #76 from concord-consortium/187399412-final-reset-fix
Browse files Browse the repository at this point in the history
fix: Working reset fix [PT-187399412]
  • Loading branch information
dougmartin authored Oct 3, 2024
2 parents 0ab337d + 119c47b commit 52a663f
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 52a663f

Please sign in to comment.