Skip to content

Commit 5d707bb

Browse files
authored
fix(web): Mod+B bolds on non-Latin layouts (#13409)
1 parent 29a3266 commit 5d707bb

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎apps/web/src/keybindings.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,20 @@ describe("isRichTextBoldShortcut", () => {
10761076
assert.isTrue(isRichTextBoldShortcut(event({ key: "B", ctrlKey: true })));
10771077
});
10781078

1079+
it("matches the B key on non-Latin layouts, like the sidebar toggle does", () => {
1080+
const cyrillicB = event({ key: "и", code: "KeyB", ctrlKey: true });
1081+
assert.isTrue(isRichTextBoldShortcut(cyrillicB));
1082+
assert.strictEqual(
1083+
resolveShortcutCommand(cyrillicB, DEFAULT_BINDINGS, { platform: "Win32" }),
1084+
"sidebar.toggle",
1085+
);
1086+
});
1087+
1088+
it("follows the letter a Latin layout types, not the physical key", () => {
1089+
assert.isFalse(isRichTextBoldShortcut(event({ key: "x", code: "KeyB", ctrlKey: true })));
1090+
assert.isTrue(isRichTextBoldShortcut(event({ key: "b", code: "KeyN", ctrlKey: true })));
1091+
});
1092+
10791093
it("ignores shifted, alted, bare, and non-keydown presses", () => {
10801094
assert.isFalse(isRichTextBoldShortcut(event({ key: "b", metaKey: true, shiftKey: true })));
10811095
assert.isFalse(isRichTextBoldShortcut(event({ key: "b", metaKey: true, altKey: true })));

‎apps/web/src/keybindings.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ export function isRichTextBoldShortcut(event: ShortcutEventLike): boolean {
425425
return false;
426426
}
427427
return (
428-
event.key.toLowerCase() === "b" &&
428+
resolveEventKeys(event).has("b") &&
429429
(event.metaKey || event.ctrlKey) &&
430430
!event.altKey &&
431431
!event.shiftKey

0 commit comments

Comments
 (0)