From 412d8e725664e1d9ef03e76fdc002256fc9735f9 Mon Sep 17 00:00:00 2001 From: Sawyer Hood Date: Thu, 10 Sep 2026 08:57:40 -0700 Subject: [PATCH] Guard palette keyboard actions during composition --- .../commands/CommandPalette.test.tsx | 27 +++++++++++++++++++ .../components/commands/CommandPalette.tsx | 1 + 2 files changed, 28 insertions(+) diff --git a/apps/app/src/components/commands/CommandPalette.test.tsx b/apps/app/src/components/commands/CommandPalette.test.tsx index 5cedfc05d72..3e184d150b9 100644 --- a/apps/app/src/components/commands/CommandPalette.test.tsx +++ b/apps/app/src/components/commands/CommandPalette.test.tsx @@ -319,6 +319,33 @@ describe("CommandPalette", () => { expect(document.activeElement).toBe(screen.getByTestId("origin")); }); + it("keeps composition confirmation separate from command activation", async () => { + renderPalette(); + openPalette(); + await waitFor(() => expect(searchField()).toBeTruthy()); + + fireEvent.change(searchField(), { target: { value: ">toggle panel" } }); + await waitFor(() => + expect(selectedOption()?.textContent).toContain("Toggle panel"), + ); + const input = searchField(); + const confirmation = new KeyboardEvent("keydown", { + key: "Enter", + isComposing: true, + bubbles: true, + cancelable: true, + }); + fireEvent(input, confirmation); + + expect(confirmation.defaultPrevented).toBe(false); + expect(screen.queryByRole("combobox")).toBe(input); + expect(testState.calls).toEqual([]); + + fireEvent.keyDown(input, { key: "Enter" }); + await waitFor(() => expect(testState.calls).toEqual(["panel.toggle"])); + expect(screen.queryByRole("combobox")).toBeNull(); + }); + it("runs a compact selection once after restoring focus", async () => { renderPalette(true); openPalette(); diff --git a/apps/app/src/components/commands/CommandPalette.tsx b/apps/app/src/components/commands/CommandPalette.tsx index cbac0ad6082..5013503a967 100644 --- a/apps/app/src/components/commands/CommandPalette.tsx +++ b/apps/app/src/components/commands/CommandPalette.tsx @@ -262,6 +262,7 @@ export function CommandPalette({ threadId, projectId }: CommandPaletteProps) { const handleKeyDown = useCallback( (event: ReactKeyboardEvent) => { + if (event.nativeEvent.isComposing) return; if (resultCount === 0) return; if (event.key === "ArrowDown") { event.preventDefault();