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: focus cells when undeleted (#7491)

Myles Scolnickd93c20c149b7
diff --git a/frontend/src/core/cells/__tests__/cells.test.ts b/frontend/src/core/cells/__tests__/cells.test.ts
index 9786fd1535..6a694104a1 100644
--- a/frontend/src/core/cells/__tests__/cells.test.ts
+++ b/frontend/src/core/cells/__tests__/cells.test.ts
@@ -218,6 +218,9 @@ describe("cell reducer", () => {
[1] ''
"
`);
+
+ // Verify scrollKey is set to the restored cell
+ expect(state.scrollKey).toBe("2" as CellId);
});
it("can delete a SQL cell and undo delete", () => {
@@ -2150,6 +2153,9 @@ describe("cell reducer", () => {
expect(state.cellData[SETUP_CELL_ID].code).toBe("# Setup code");
expect(state.cellData[SETUP_CELL_ID].edited).toBe(true);
expect(state.cellIds.inOrderIds).toContain(SETUP_CELL_ID);
+
+ // Verify scrollKey is set to the restored setup cell
+ expect(state.scrollKey).toBe(SETUP_CELL_ID);
});
it("can delete and then create a new setup cell", () => {
diff --git a/frontend/src/core/cells/cells.ts b/frontend/src/core/cells/cells.ts
index 556b0ca071..6e1f94996d 100644
--- a/frontend/src/core/cells/cells.ts
+++ b/frontend/src/core/cells/cells.ts
@@ -646,6 +646,8 @@ const {
[cellId]: createRef(),
},
history: state.history.slice(0, -1),
+ // Scroll to the newly created cell
+ scrollKey: cellId,
};
},
clearSerializedEditorState: (state, action: { cellId: CellId }) => {