From 5d707bb71de19eb0eb6fe4688602ee853aec2e3c Mon Sep 17 00:00:00 2001 From: ValeraZSD <48602572+ValeraZSD@users.noreply.github.com> Date: Sat, 26 Sep 2026 06:14:52 +0200 Subject: [PATCH] fix(web): Mod+B bolds on non-Latin layouts (#13409) --- apps/web/src/keybindings.test.ts | 14 ++++++++++++++ apps/web/src/keybindings.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/web/src/keybindings.test.ts b/apps/web/src/keybindings.test.ts index 2d9da2e5ebc1f14b2d94fd227291bc67c6813bf7..e568e06cb31dd7dfbbe04a3700ff29c514389408 100644 --- a/apps/web/src/keybindings.test.ts +++ b/apps/web/src/keybindings.test.ts @@ -1076,6 +1076,20 @@ describe("isRichTextBoldShortcut", () => { assert.isTrue(isRichTextBoldShortcut(event({ key: "B", ctrlKey: true }))); }); + it("matches the B key on non-Latin layouts, like the sidebar toggle does", () => { + const cyrillicB = event({ key: "и", code: "KeyB", ctrlKey: true }); + assert.isTrue(isRichTextBoldShortcut(cyrillicB)); + assert.strictEqual( + resolveShortcutCommand(cyrillicB, DEFAULT_BINDINGS, { platform: "Win32" }), + "sidebar.toggle", + ); + }); + + it("follows the letter a Latin layout types, not the physical key", () => { + assert.isFalse(isRichTextBoldShortcut(event({ key: "x", code: "KeyB", ctrlKey: true }))); + assert.isTrue(isRichTextBoldShortcut(event({ key: "b", code: "KeyN", ctrlKey: true }))); + }); + it("ignores shifted, alted, bare, and non-keydown presses", () => { assert.isFalse(isRichTextBoldShortcut(event({ key: "b", metaKey: true, shiftKey: true }))); assert.isFalse(isRichTextBoldShortcut(event({ key: "b", metaKey: true, altKey: true }))); diff --git a/apps/web/src/keybindings.ts b/apps/web/src/keybindings.ts index b615d3564437f329203326af8214d746b4e5c6ba..73b59bc20b29cafc299a869221eeb47f5382ad98 100644 --- a/apps/web/src/keybindings.ts +++ b/apps/web/src/keybindings.ts @@ -425,7 +425,7 @@ export function isRichTextBoldShortcut(event: ShortcutEventLike): boolean { return false; } return ( - event.key.toLowerCase() === "b" && + resolveEventKeys(event).has("b") && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey -- 2.54.0