Skip to content

Commit fd0a766

Browse files
committed
fix: Ctrl+I leaves focus in an open command palette
1 parent a2db165 commit fd0a766

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

‎src/browser/features/ChatInput/index.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,10 @@ const ChatInputInner: React.FC<ChatInputProps> = (props) => {
13591359
return;
13601360
}
13611361
event.preventDefault();
1362-
if (!isDialogOpen()) focusMessageInput();
1362+
// isDialogOpen() misses the command palette (cmdk); focus must not move behind it.
1363+
const inCommandPalette =
1364+
event.target instanceof Element && event.target.closest("[cmdk-root]") != null;
1365+
if (!isDialogOpen() && !inCommandPalette) focusMessageInput();
13631366
};
13641367
window.addEventListener("keydown", handleFocusChat, { capture: true });
13651368
return () => window.removeEventListener("keydown", handleFocusChat, { capture: true });

‎tests/bugbash/repros/focusAndLabels.e2e.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ test(
2222

2323
await browser.keyboard.press("Control+i");
2424
await expect(composer).toBeFocused();
25+
26+
// With the command palette open, Ctrl+I leaves focus in the palette.
27+
await browser.keyboard.press("Control+Shift+P");
28+
const palette = screen.getByRole("combobox", "Command palette");
29+
await expect(palette).toBeFocused();
30+
await browser.keyboard.press("Control+i");
31+
await expect(palette).toBeFocused();
2532
}
2633
);
2734

0 commit comments

Comments
 (0)