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: focus on the first cell when editing on startup (#41)

Myles Scolnick4dee2c12a5b4
diff --git a/frontend/src/editor/renderers/CellArray.tsx b/frontend/src/editor/renderers/CellArray.tsx
index 10e0497e2b..614cee197a 100644
--- a/frontend/src/editor/renderers/CellArray.tsx
+++ b/frontend/src/editor/renderers/CellArray.tsx
@@ -59,8 +59,10 @@ export const CellArray: React.FC<CellArrayProps> = ({
const delay = Math.max(Math.min((cells.present.length - 1) * 15, 100), 0);
const timeout = setTimeout(() => {
setInvisible(false);
- // Focus on the first cell if it's been mounted
- cells.present[0]?.ref.current?.editorView.focus();
+ // After 1 frame, focus on the first cell if it's been mounted
+ requestAnimationFrame(() => {
+ cells.present[0]?.ref.current?.editorView.focus();
+ });
}, delay);
return () => clearTimeout(timeout);
// Delay only when app is first loaded