Skip to content

Commit b279353

Browse files
SepehrRajabiclaude
andcommitted
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 <[email protected]>
1 parent 4ee6bfd commit b279353

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ function SidebarControl() {
105105
if (
106106
isRichTextBoldShortcut(event) &&
107107
event.target instanceof HTMLElement &&
108-
event.target.closest('[data-composer-rich-text="true"]')
108+
event.target.closest('[data-composer-rich-text="true"]') &&
109+
window.getSelection()?.isCollapsed === false
109110
) {
110-
// The rich-text composer claims Mod+B for bold; the toggle stays
111-
// available everywhere else, including the plain-text composer.
111+
// The rich-text composer claims Mod+B to bold selected text. Without a
112+
// selection the toggle wins, since the composer holds focus most of the time.
112113
return;
113114
}
114115
if (

‎apps/web/src/keybindings.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ export function isOpenFavoriteEditorShortcut(
422422
/**
423423
* Whether the keypress is the rich-text bold chord (Mod+B without extra
424424
* modifiers). Tiptap binds the same chord, so app shortcuts captured ahead
425-
* of the editor must yield when the rich-text composer is focused.
425+
* of the editor must yield when the rich-text composer has text selected.
426426
*/
427427
export function isRichTextBoldShortcut(event: ShortcutEventLike): boolean {
428428
if (event.type !== undefined && event.type !== "keydown") {

0 commit comments

Comments
 (0)