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.

improvement: position hide code button above or below depending on outputArea (#3522)

Shahmir Varqhafcadec7c7e8d
diff --git a/frontend/src/components/editor/Cell.tsx b/frontend/src/components/editor/Cell.tsx
index fbfe3eb642..4ef325a49c 100644
--- a/frontend/src/components/editor/Cell.tsx
+++ b/frontend/src/components/editor/Cell.tsx
@@ -373,6 +373,18 @@ const CellComponent = (
};
const hasOutput = !isOutputEmpty(output);
+ const cellOutput = userConfig.display.cell_output;
+
+ const hasOutputAbove = hasOutput && cellOutput === "above";
+ const hasOutputBelow = hasOutput && cellOutput === "below";
+
+ const hideCodeButton = (className: string) => (
+ <HideCodeButton
+ tooltip="Edit markdown"
+ className={cn("z-20 relative", className)}
+ onClick={temporarilyShowCode}
+ />
+ );
const outputArea = hasOutput && (
<div className="relative" onDoubleClick={showHiddenMarkdownCode}>
@@ -389,6 +401,7 @@ const CellComponent = (
canCollapse={canCollapse}
/>
</div>
+ {isMarkdownCodeHidden && hasOutputBelow && hideCodeButton("top-3")}
<OutputArea
// Only allow expanding in edit mode
allowExpand={editing}
@@ -399,13 +412,7 @@ const CellComponent = (
cellId={cellId}
stale={outputStale}
/>
- {isMarkdownCodeHidden && (
- <HideCodeButton
- tooltip="Edit markdown"
- className="z-20 relative -top-3"
- onClick={temporarilyShowCode}
- />
- )}
+ {isMarkdownCodeHidden && hasOutputAbove && hideCodeButton("bottom-3")}
</div>
);
@@ -567,11 +574,6 @@ const CellComponent = (
/>
);
- const cellOutput = userConfig.display.cell_output;
-
- const hasOutputAbove = hasOutput && cellOutput === "above";
- const hasOutputBelow = hasOutput && cellOutput === "below";
-
return (
<CellActionsContextMenu
cellId={cellId}