Skip to content

Commit 0f184c2

Browse files
authored
fix(web): use capture-phase keydown listener so CTRL+J toggles terminal from terminal focus on Windows (#2113) (#2142)
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
1 parent a3b1df5 commit 0f184c2

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)