authorgravatar for bortstheboat@gmail.comAndrew Barnes <bortstheboat@gmail.com> 2026-07-20 04:33:43-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-07-20 08:33:43+00:00
logdfbda843628c817a48523b1a4a28a6ef232d1d65
tree06d550e17300cbb05f6693664838bcd0f1eafcf7
parent78485e6d50d06180618aacd0d25151e831f666a4
signature Signed by PGP key B5690EEEBB952194

fix(web): handle sidebar shortcut before editors (#3921)


2 files changed, 11 insertions(+), 2 deletions(-)

apps/web/src/components/AppSidebarLayout.tsx+9-2
......@@ -33,6 +33,12 @@ function SidebarControl() {
3333 useEffect(() => {
3434 const onKeyDown = (event: KeyboardEvent) => {
3535 if (event.defaultPrevented) return;
36 if (
37 event.target instanceof HTMLElement &&
38 event.target.closest("[data-keybinding-capture]")
39 ) {
40 return;
41 }
3642 if (resolveShortcutCommand(event, keybindings) !== "sidebar.toggle") return;
3743
3844 event.preventDefault();
......@@ -40,8 +46,9 @@ function SidebarControl() {
4046 toggleSidebar();
4147 };
4248
43 window.addEventListener("keydown", onKeyDown);
44 return () => window.removeEventListener("keydown", onKeyDown);
49 // Capture before focused editors consume commands such as Mod+B for rich-text formatting.
50 window.addEventListener("keydown", onKeyDown, true);
51 return () => window.removeEventListener("keydown", onKeyDown, true);
4552 }, [keybindings, toggleSidebar]);
4653
4754 return (
apps/web/src/components/settings/KeybindingsSettings.tsx+2
......@@ -846,6 +846,7 @@ function KeybindingTableRow({
846846 </button>
847847 ) : (
848848 <Input
849 data-keybinding-capture=""
849850 autoFocus={isRecording}
850851 aria-label={`Keybinding for ${commandLabel(row.command)}`}
851852 value={isRecording ? "" : keyDraft}
......@@ -1011,6 +1012,7 @@ function NewKeybindingTableRow({
10111012 </div>
10121013 <div className="flex min-w-0 items-center gap-2 pr-4">
10131014 <Input
1015 data-keybinding-capture=""
10141016 aria-label={`Keybinding for ${commandLabelText}`}
10151017 value={isRecording ? "" : keyDraft}
10161018 placeholder={isRecording ? "Press shortcut" : "Unassigned"}