Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): right panel launcher letters open their surface instead of typing into the composer #22898

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/22898/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 2 changed files with 101 additions and 0 deletions.

x
0 of 2 viewed, 2 left
12 additions and 0 deletionsapps/web/src/components/chat/composerFocusRedirect.tsModified
View file
@@ -47,6 +47,17 @@
​
const SECRET_REQUEST_SELECTOR = '[data-v2-item-type="secret_request"]';
+const SURFACE_LAUNCHER_KEYS_ATTRIBUTE = "data-surface-launcher-keys";
+​
+// 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 {
+ const launcherKeys = document
+ .querySelector(`[${SURFACE_LAUNCHER_KEYS_ATTRIBUTE}]`)
+ ?.getAttribute(SURFACE_LAUNCHER_KEYS_ATTRIBUTE);
+ return launcherKeys?.toLowerCase().includes(key.toLowerCase()) ?? false;
+}
​
export function shouldRedirectInputToComposer(event: Event): boolean {
if (event.defaultPrevented) return false;
@@ -64,6 +75,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;
​
return true;