Skip to content
TypeScript

fix(web): Mod+B bolds on non-Latin layouts (#13409)

ValeraZSD5d707bb71de1
diff --git a/apps/web/src/keybindings.test.ts b/apps/web/src/keybindings.test.ts
index 2d9da2e5ebc..e568e06cb31 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 b615d356443..73b59bc20b2 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