Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): right panel launcher letters work on non-Latin keyboard layouts #21508

MergedMarMarLabs(GitHub profile, opens in a new tab)merged 11 commits intomain fromrefs/pull/21508/headmerged by maria-rcks View on GitHub

Showing 5 changed files with 116 additions and 5 deletions (loading 2).

x
0 of 5 viewed, 5 left
8 additions and 4 deletionsapps/web/src/components/chat/composerFocusRedirect.tsModified
View file
@@ -1,3 +1,5 @@
+import { surfaceShortcutKey } from "~/lib/surfaceShortcutKey";
+​
export const TYPE_TO_FOCUS_EDITABLE_SELECTOR = [
"input",
"textarea",
@@ -48,11 +50,13 @@
// The right-panel launcher registers its own window capture listener when it
// mounts. When the panel opens after page load that listener runs after ours,
// so we must leave its letters alone or the composer takes them first.
-function isSurfaceLauncherKey(key: string): boolean {
+function isSurfaceLauncherKey(event: KeyboardEvent): boolean {
const launcherKeys = document
.querySelector(`[${SURFACE_LAUNCHER_KEYS_ATTRIBUTE}]`)
- ?.getAttribute(SURFACE_LAUNCHER_KEYS_ATTRIBUTE);
- return launcherKeys?.toLowerCase().includes(key.toLowerCase()) ?? false;
+ ?.getAttribute(SURFACE_LAUNCHER_KEYS_ATTRIBUTE)
+ ?.toLowerCase();
+ const key = surfaceShortcutKey(event);
+ return key !== null && (launcherKeys?.includes(key) ?? false);
​
export function shouldRedirectInputToComposer(event: Event): boolean {
@@ -70,7 +74,7 @@
if (event.metaKey || event.ctrlKey || event.altKey) return false;
if (event.key.length !== 1) return false;
if (!shouldRedirectInputToComposer(event)) return false;
- if (isSurfaceLauncherKey(event.key)) return false;
+ if (isSurfaceLauncherKey(event)) return false;