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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Run cell actions after restoring menu focus (#11614)
Trevor Manz1d436d5927a4
diff --git a/frontend/e2e-tests/toggle-cell-language.spec.ts b/frontend/e2e-tests/toggle-cell-language.spec.tsindex 3380a05040..5d05a7fa9a 100644--- a/frontend/e2e-tests/toggle-cell-language.spec.ts+++ b/frontend/e2e-tests/toggle-cell-language.spec.ts@@ -42,6 +42,7 @@ test("change the cell to a markdown cell and toggle hide code", async ({await openCellActions(page, title);await page.getByText("Show code").click();await expect(cellEditor).toBeVisible();+ await expect(cellEditor.locator(".cm-content")).toBeFocused();// Hide codeawait openCellActions(page, title);diff --git a/frontend/src/components/editor/cell/cell-actions.tsx b/frontend/src/components/editor/cell/cell-actions.tsxindex ca0d56cf6b..de0cff9f85 100644--- a/frontend/src/components/editor/cell/cell-actions.tsx+++ b/frontend/src/components/editor/cell/cell-actions.tsx@@ -60,6 +60,7 @@ const CellActionsDropdownInternal = (ref: React.Ref<CellActionsDropdownHandle>,) => {const [open, setOpen] = useState(false);+ const pendingAction = useRef<(() => void) | null>(null);const closePopover = () => setOpen(false);const buttonRef = useRef<HTMLButtonElement>(null);const actions = useCellActionButtons({ cell: props, closePopover });@@ -107,6 +108,16 @@ const CellActionsDropdownInternal = (className="w-[300px] p-0 pt-1 overflow-auto"scrollable={true}{...restoreFocus}+ onCloseAutoFocus={(event) => {+ restoreFocus.onCloseAutoFocus(event);+ const action = pendingAction.current;+ pendingAction.current = null;+ if (action) {+ // Restore focus before the action moves it or hides the editor.+ event.preventDefault();+ action();+ }+ }}><Command><CommandInput@@ -153,7 +164,7 @@ const CellActionsDropdownInternal = (if (action.disableClick || action.disabled) {return;}- action.handle();+ pendingAction.current = action.handle;setOpen(false);}}variant={action.variant}