diff --git a/packages/gitbook/src/components/AIChat/AIChatInput.tsx b/packages/gitbook/src/components/AIChat/AIChatInput.tsx index ee9ca5aca2..074ec60d6c 100644 --- a/packages/gitbook/src/components/AIChat/AIChatInput.tsx +++ b/packages/gitbook/src/components/AIChat/AIChatInput.tsx @@ -34,7 +34,13 @@ export function AIChatInput(props: { useEffect(() => { if (!disabled && !loading) { - inputRef.current?.focus(); + // Add a small delay to ensure the input is rendered before focusing + // This fixes inconsistent focus behaviour across browsers + const timeout = setTimeout(() => { + inputRef.current?.focus(); + }, 50); + + return () => clearTimeout(timeout); } }, [disabled, loading]); @@ -120,8 +126,8 @@ export function AIChatInput(props: { arrow >