Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions apps/web/src/components/AppSidebarLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,20 @@ 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"]')
richComposer &&
selection?.isCollapsed === false &&
richComposer.contains(selection.anchorNode) &&
richComposer.contains(selection.focusNode)
) {
// 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 its selected text. Without a
// selection the toggle wins, since the composer holds focus most of the time.
return;
}
if (
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/keybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
Loading