Skip to content
TypeScript

fix(web): clicking a secret request card focuses its field again (#26151)

Matthew Feroz22463861cd2f
diff --git a/apps/web/src/components/chat/SecretRequestCard.tsx b/apps/web/src/components/chat/SecretRequestCard.tsx
index 510d838add2..2ec2923b88b 100644
--- a/apps/web/src/components/chat/SecretRequestCard.tsx
+++ b/apps/web/src/components/chat/SecretRequestCard.tsx
@@ -102,9 +102,13 @@ function PendingSecretRequestForm(props: {
className="flex min-w-0 flex-col gap-3 rounded-xl border border-border/60 bg-card p-4"
onSubmit={onSubmit}
autoComplete="off"
- onPointerDown={(event) => {
- if (!(event.target instanceof HTMLElement)) return;
+ // On click, not pointerdown: the mousedown that follows a pointerdown
+ // moves focus back off the input. A click that ends a text selection
+ // leaves it alone so the reason can still be copied.
+ onClick={(event) => {
+ if (!(event.target instanceof Element)) return;
if (event.target.closest("input, button, a")) return;
+ if (window.getSelection()?.isCollapsed === false) return;
document.getElementById(inputId)?.focus();
}}
>