From b279353da56990af797b35f09921ae5936f7af59 Mon Sep 17 00:00:00 2001 From: Sepehr Rajabi Date: Sun, 4 Oct 2026 23:10:24 +0200 Subject: [PATCH 1/2] fix(web): mod+b toggles the sidebar unless composer text is selected The rich-text composer claimed Mod+B for bold whenever it had focus, and the app keeps focus there most of the time, so the sidebar shortcut rarely fired. Bold now takes Mod+B only when composer text is selected. Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/AppSidebarLayout.tsx | 7 ++++--- apps/web/src/keybindings.ts | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/AppSidebarLayout.tsx b/apps/web/src/components/AppSidebarLayout.tsx index 918d28845068a..8653e9df98bfa 100644 --- a/apps/web/src/components/AppSidebarLayout.tsx +++ b/apps/web/src/components/AppSidebarLayout.tsx @@ -105,10 +105,11 @@ function SidebarControl() { if ( isRichTextBoldShortcut(event) && event.target instanceof HTMLElement && - event.target.closest('[data-composer-rich-text="true"]') + event.target.closest('[data-composer-rich-text="true"]') && + window.getSelection()?.isCollapsed === false ) { - // The rich-text composer claims Mod+B for bold; the toggle stays - // available everywhere else, including the plain-text composer. + // The rich-text composer claims Mod+B to bold selected text. Without a + // selection the toggle wins, since the composer holds focus most of the time. return; } if ( diff --git a/apps/web/src/keybindings.ts b/apps/web/src/keybindings.ts index 24a4676050340..49f23b0f4a5ab 100644 --- a/apps/web/src/keybindings.ts +++ b/apps/web/src/keybindings.ts @@ -422,7 +422,7 @@ export function isOpenFavoriteEditorShortcut( /** * Whether the keypress is the rich-text bold chord (Mod+B without extra * modifiers). Tiptap binds the same chord, so app shortcuts captured ahead - * of the editor must yield when the rich-text composer is focused. + * of the editor must yield when the rich-text composer has text selected. */ export function isRichTextBoldShortcut(event: ShortcutEventLike): boolean { if (event.type !== undefined && event.type !== "keydown") { From ea1a1d5bbd20fd85f697b59d20defbc72071dc9e Mon Sep 17 00:00:00 2001 From: Sepehr Rajabi Date: Mon, 5 Oct 2026 10:38:43 +0200 Subject: [PATCH 2/2] fix(web): only yield mod+b when the selection is inside the composer Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/AppSidebarLayout.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/AppSidebarLayout.tsx b/apps/web/src/components/AppSidebarLayout.tsx index 8653e9df98bfa..ecf9866356967 100644 --- a/apps/web/src/components/AppSidebarLayout.tsx +++ b/apps/web/src/components/AppSidebarLayout.tsx @@ -102,13 +102,19 @@ function SidebarControl() { ) { return; } + const richComposer = + event.target instanceof HTMLElement + ? event.target.closest('[data-composer-rich-text="true"]') + : null; + const selection = window.getSelection(); if ( isRichTextBoldShortcut(event) && - event.target instanceof HTMLElement && - event.target.closest('[data-composer-rich-text="true"]') && - window.getSelection()?.isCollapsed === false + richComposer && + selection?.isCollapsed === false && + richComposer.contains(selection.anchorNode) && + richComposer.contains(selection.focusNode) ) { - // The rich-text composer claims Mod+B to bold selected text. Without a + // The rich-text composer claims Mod+B to bold its selected text. Without a // selection the toggle wins, since the composer holds focus most of the time. return; }