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.

improve: temporarily show code (#2504)

Akshay Agrawal68bfd9d0dfd4
diff --git a/frontend/src/components/editor/cell/code/cell-editor.tsx b/frontend/src/components/editor/cell/code/cell-editor.tsx
index 0ea2383831..4aeb1503a9 100644
--- a/frontend/src/components/editor/cell/code/cell-editor.tsx
+++ b/frontend/src/components/editor/cell/code/cell-editor.tsx
@@ -325,12 +325,15 @@ const CellEditorInternal = ({
};
}, [editorViewRef]);
- const showCode = async () => {
+ const temporarilyShowCode = async () => {
if (hidden) {
- await saveCellConfig({ configs: { [cellId]: { hide_code: false } } });
updateCellConfig({ cellId, config: { hide_code: false } });
- // Focus on the editor view
editorViewRef.current?.focus();
+ editorViewRef.current?.contentDOM.addEventListener(
+ "blur",
+ () => updateCellConfig({ cellId, config: { hide_code: true } }),
+ { once: true },
+ );
}
};
@@ -369,7 +372,7 @@ const CellEditorInternal = ({
className="relative w-full"
onFocus={() => setLastFocusedCellId(cellId)}
>
- {hidden && <HideCodeButton onClick={showCode} />}
+ {hidden && <HideCodeButton onClick={temporarilyShowCode} />}
<CellCodeMirrorEditor
className={cn(hidden && "opacity-20 h-8 overflow-hidden")}
editorView={editorViewRef.current}