Skip to content

Commit 5ffb946

Browse files
committed
fix(web): use capture-phase keydown listener so terminal toggle works while terminal has focus
Fixes #2113
1 parent 4e0c003 commit 5ffb946

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,8 +2290,8 @@ export default function ChatView(props: ChatViewProps) {
22902290
event.stopPropagation();
22912291
void runProjectScript(script);
22922292
};
2293-
window.addEventListener("keydown", handler);
2294-
return () => window.removeEventListener("keydown", handler);
2293+
window.addEventListener("keydown", handler, true);
2294+
return () => window.removeEventListener("keydown", handler, true);
22952295
}, [
22962296
activeProject,
22972297
terminalState.terminalOpen,

‎apps/web/src/keybindings.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,15 @@ describe("isTerminalToggleShortcut", () => {
131131
isTerminalToggleShortcut(event({ ctrlKey: true }), DEFAULT_BINDINGS, { platform: "Win32" }),
132132
);
133133
});
134+
135+
it("matches Ctrl+J on non-macOS while terminalFocus is true", () => {
136+
assert.isTrue(
137+
isTerminalToggleShortcut(event({ ctrlKey: true }), DEFAULT_BINDINGS, {
138+
platform: "Win32",
139+
context: { terminalFocus: true },
140+
}),
141+
);
142+
});
134143
});
135144

136145
describe("split/new/close terminal shortcuts", () => {

0 commit comments

Comments
 (0)