fix(web): right panel launcher letters work on non-Latin keyboard layouts #21508
MergedMarMarLabs(GitHub profile, opens in a new tab)merged 11 commits into
main fromrefs/pull/21508/headmerged by maria-rcks View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
- apps/web/src/components/RightPanelTabs.tsx lines 259 to 261OutdatedResolvedby MarMarLabs(GitHub profile, opens in a new tab)@@ -245,10 +245,17 @@245245 type SurfaceShortcutEvent = Pick<246246 KeyboardEvent,247247 "altKey" | "ctrlKey" | "defaultPrevented" | "isComposing" | "key" | "metaKey"248->;248+> &249+ Partial<Pick<KeyboardEvent, "code">>;249250250251 export function surfaceShortcutActionForKey<251252 const Action extends { available: boolean; shortcut: string },252253 >(actions: readonly Action[], event: SurfaceShortcutEvent): Action | null {253254 if (event.defaultPrevented || event.isComposing) return null;254255 if (event.metaKey || event.ctrlKey || event.altKey) return null;256+ const typed = event.key.toLowerCase();257+ // A layout that types a non-Latin letter matches by physical key, like the258+ // modified shortcuts in keybindings.ts. Latin layouts keep the typed letter.259+ const physical = /^[a-z]$/.test(typed)260+ ? undefined261+ : event.code?.match(/^Key([A-Z])$/)?.[1]?.toLowerCase();
- apps/web/src/components/RightPanelTabs.tsx lines 256 to 267OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -249,10 +250,18 @@249250250251 export function surfaceShortcutActionForKey<251252 const Action extends { available: boolean; shortcut: string },252253 >(actions: readonly Action[], event: SurfaceShortcutEvent): Action | null {253254 if (event.defaultPrevented || event.isComposing) return null;254255 if (event.metaKey || event.ctrlKey || event.altKey) return null;256+ const typed = event.key.toLowerCase();257+ // A layout that types a non-Latin letter matches by physical key, like the258+ // modified shortcuts in keybindings.ts. Latin layouts keep the typed letter.259+ const physical = /^[a-z]$/.test(typed)260+ ? undefined261+ : event.code?.match(/^Key([A-Z])$/)?.[1]?.toLowerCase();255262 return (256- actions.find(257- (action) => action.available && action.shortcut.toLowerCase() === event.key.toLowerCase(),258- ) ?? null263+ actions.find((action) => {264+ if (!action.available) return false;265+ const shortcut = action.shortcut.toLowerCase();266+ return shortcut === typed || shortcut === physical;267+ }) ?? null
- apps/web/src/components/RightPanelTabs.tsx line 262OutdatedResolvedby MarMarLabs(GitHub profile, opens in a new tab)@@ -245,10 +245,18 @@245245 type SurfaceShortcutEvent = Pick<246246 KeyboardEvent,247247 "altKey" | "ctrlKey" | "defaultPrevented" | "isComposing" | "key" | "metaKey"248->;248+> &249+ Partial<Pick<KeyboardEvent, "code">>;249250250251 export function surfaceShortcutActionForKey<251252 const Action extends { available: boolean; shortcut: string },252253 >(actions: readonly Action[], event: SurfaceShortcutEvent): Action | null {253254 if (event.defaultPrevented || event.isComposing) return null;254255 if (event.metaKey || event.ctrlKey || event.altKey) return null;256+ const typed = event.key.toLowerCase();257+ // A layout that types a non-Latin letter or combining mark matches by258+ // physical key, like the modified shortcuts in keybindings.ts. Any other259+ // key, such as an accented Latin letter, punctuation or a dead key, matches260+ // only what it types.261+ const physical =262+ /^[\p{L}\p{M}]$/u.test(typed) && !/\p{Script=Latin}/u.test(typed)
- apps/web/src/components/RightPanelTabs.tsx lines 263 to 264OutdatedResolvedby MarMarLabs(GitHub profile, opens in a new tab)@@ -245,10 +245,20 @@245245 type SurfaceShortcutEvent = Pick<246246 KeyboardEvent,247247 "altKey" | "ctrlKey" | "defaultPrevented" | "isComposing" | "key" | "metaKey"248->;248+> &249+ Partial<Pick<KeyboardEvent, "code">>;249250250251 export function surfaceShortcutActionForKey<251252 const Action extends { available: boolean; shortcut: string },252253 >(actions: readonly Action[], event: SurfaceShortcutEvent): Action | null {253254 if (event.defaultPrevented || event.isComposing) return null;254255 if (event.metaKey || event.ctrlKey || event.altKey) return null;256+ const typed = event.key.toLowerCase();257+ // A layout that types non-Latin letters or combining marks matches by258+ // physical key, like the modified shortcuts in keybindings.ts. One key can259+ // type several, such as the Arabic lam alef ligature. Any other key, such as260+ // an accented Latin letter, punctuation or a dead key, matches only what it261+ // types.262+ const physical =263+ /^[\p{L}\p{M}]+$/u.test(typed) && !/\p{Script=Latin}/u.test(typed)264+ ? event.code?.match(/^Key([A-Z])$/)?.[1]?.toLowerCase()
- apps/web/src/components/RightPanelTabs.tsx line 271OutdatedResolvedby MarMarLabs(GitHub profile, opens in a new tab)@@ -252,6 +251,21 @@251+> &252+ Partial<Pick<KeyboardEvent, "code" | "getModifierState">>;252253253254 export function surfaceShortcutActionForKey<254255 const Action extends { available: boolean; shortcut: string },255256 >(actions: readonly Action[], event: SurfaceShortcutEvent): Action | null {256257 if (event.defaultPrevented || event.isComposing) return null;257258 if (event.metaKey || event.ctrlKey || event.altKey) return null;259+ // Linux and Windows report AltGr as AltGraph without Ctrl or Alt, which the260+ // check above misses, while macOS Option always sets altKey. As in261+ // keybindings.ts, AltGr text other than a plain letter or digit, like the262+ // micro sign on German AltGr+M, is not a launcher letter.263+ if (event.getModifierState?.("AltGraph") && !/^[a-z0-9]$/i.test(event.key)) return null;264+ const typed = event.key.toLowerCase();265+ // A layout that types non-Latin letters or combining marks matches by266+ // physical key, like the modified shortcuts in keybindings.ts. One key can267+ // type several, such as the Arabic lam alef ligature. Any other key, such as268+ // an accented Latin letter, punctuation or a dead key, matches only what it269+ // types.270+ const physical =271+ /^[\p{L}\p{M}]+$/u.test(typed) && !/\p{Script=Latin}/u.test(typed)
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
maria-rcks merged thise836ab1
maria-rcks closed this
Sign in to join this conversation.




Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
We couldn’t complete this review. Comment
@codex reviewto try again.f6ccdffℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.