Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Handle edge cases when double clicking dep graph (#326)

Myles Scolnick09faa2160a5f
diff --git a/frontend/src/components/dependency-graph/dependency-graph.tsx b/frontend/src/components/dependency-graph/dependency-graph.tsx
index 01c4e0d08c..2828af5607 100644
--- a/frontend/src/components/dependency-graph/dependency-graph.tsx
+++ b/frontend/src/components/dependency-graph/dependency-graph.tsx
@@ -62,7 +62,8 @@ const DependencyGraphInternal: React.FC<Props> = ({
const { nodes, edges } = createElements(cellIds, cellAtoms, variables);
setNodes(nodes);
setAllEdges(edges);
- }, [cellIds, setNodes, variables, cellAtoms, setAllEdges]);
+ setEdges([]);
+ }, [cellIds, setNodes, variables, cellAtoms, setAllEdges, setEdges]);
// If the selected node changes, update the edges.
useEffect(() => {
@@ -76,8 +77,6 @@ const DependencyGraphInternal: React.FC<Props> = ({
);
});
setEdges(selectedEdges);
- } else {
- setEdges([]);
}
}, [selectedNodeId, setEdges, allEdges]);
@@ -103,7 +102,11 @@ const DependencyGraphInternal: React.FC<Props> = ({
translateExtent={translateExtent}
onNodeClick={(_event, node) => {
const id = node.id;
+ if (id === selectedNodeId) {
+ return;
+ }
setSelectedNodeId(id);
+ setEdges([]);
}}
// On
snapToGrid={true}