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.

fix: allow closing active selection in dep viewer, fix table memo (#2758)

Myles Scolnickc90743defeec
diff --git a/frontend/src/components/data-table/data-table.tsx b/frontend/src/components/data-table/data-table.tsx
index 1c0953c6c2..1be64114cf 100644
--- a/frontend/src/components/data-table/data-table.tsx
+++ b/frontend/src/components/data-table/data-table.tsx
@@ -1,4 +1,8 @@
/* Copyright 2024 Marimo. All rights reserved. */
+"use no memo";
+// tanstack/table is not compatible with React compiler
+// https://github.com/TanStack/table/issues/5567
+
import React, { memo } from "react";
import {
type ColumnDef,
diff --git a/frontend/src/components/dependency-graph/dependency-graph-minimap.tsx b/frontend/src/components/dependency-graph/dependency-graph-minimap.tsx
index 1a1ea3199a..724ef0f37f 100644
--- a/frontend/src/components/dependency-graph/dependency-graph-minimap.tsx
+++ b/frontend/src/components/dependency-graph/dependency-graph-minimap.tsx
@@ -92,6 +92,11 @@ export const DependencyGraphMinimap: React.FC<PropsWithChildren<Props>> = ({
const translateExtent = useTranslateExtent(nodes, height);
+ const handleClearSelection = () => {
+ setSelectedNodeId(undefined);
+ setSelectedEdge(undefined);
+ };
+
const renderGraphSelectionPanel = () => {
if (selectedEdge) {
return (
@@ -101,6 +106,7 @@ export const DependencyGraphMinimap: React.FC<PropsWithChildren<Props>> = ({
source: selectedEdge.source as CellId,
target: selectedEdge.target as CellId,
}}
+ onClearSelection={handleClearSelection}
variables={variables}
edges={edges}
/>
@@ -112,6 +118,7 @@ export const DependencyGraphMinimap: React.FC<PropsWithChildren<Props>> = ({
selection={{ type: "node", id: selectedNodeId }}
variables={variables}
edges={edges}
+ onClearSelection={handleClearSelection}
/>
);
}
diff --git a/frontend/src/components/dependency-graph/dependency-graph-tree.tsx b/frontend/src/components/dependency-graph/dependency-graph-tree.tsx
index caa1deb7c0..4a86c17dfc 100644
--- a/frontend/src/components/dependency-graph/dependency-graph-tree.tsx
+++ b/frontend/src/components/dependency-graph/dependency-graph-tree.tsx
@@ -103,6 +103,10 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
const [selection, setSelection] = useState<GraphSelection>();
useFitToViewOnDimensionChange();
+ const handleClearSelection = () => {
+ setSelection(undefined);
+ };
+
return (
<EdgeMarkerContext.Provider value={layoutDirection}>
<ReactFlow
@@ -138,7 +142,6 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
<Controls position="bottom-right" showInteractive={false}>
<Tooltip
content="Jump to focused cell"
- usePortal={false}
delayDuration={200}
side="left"
asChild={false}
@@ -171,6 +174,7 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
selection={selection}
variables={variables}
edges={edges}
+ onClearSelection={handleClearSelection}
/>
{children}
</ReactFlow>
diff --git a/frontend/src/components/dependency-graph/panels.tsx b/frontend/src/components/dependency-graph/panels.tsx
index 9a82fd7a52..e2a7d04212 100644
--- a/frontend/src/components/dependency-graph/panels.tsx
+++ b/frontend/src/components/dependency-graph/panels.tsx
@@ -12,6 +12,7 @@ import {
SquareFunction,
SettingsIcon,
MoreVerticalIcon,
+ XIcon,
} from "lucide-react";
import type { GraphLayoutView, GraphSelection, GraphSettings } from "./types";
import { CellLink } from "../editor/links/cell-link";
@@ -109,9 +110,10 @@ GraphToolbar.displayName = "GraphToolbar";
export const GraphSelectionPanel: React.FC<{
selection: GraphSelection;
+ onClearSelection: () => void;
edges: Edge[];
variables: Variables;
-}> = memo(({ selection, edges, variables }) => {
+}> = memo(({ selection, edges, variables, onClearSelection }) => {
if (!selection) {
return null;
}
@@ -189,6 +191,15 @@ export const GraphSelectionPanel: React.FC<{
<MoreVerticalIcon className="w-4 h-4" />
</Button>
</ConnectionCellActionsDropdown>
+ <Button
+ variant="text"
+ size="icon"
+ onClick={() => {
+ onClearSelection();
+ }}
+ >
+ <XIcon className="w-4 h-4" />
+ </Button>
</div>
<div className="text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center">
<div className="flex flex-col gap-2">