From 714087ca5a1daeb7cf62d2990e71fee8ccfd19c6 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Fri, 1 Aug 2025 12:29:44 +0300 Subject: [PATCH] docs: fix search not opening sometimes (#13118) --- .../src/components/AiAssistant/ChatWindow/Input/index.tsx | 4 +++- www/packages/docs-ui/src/providers/AiAssistant/index.tsx | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/www/packages/docs-ui/src/components/AiAssistant/ChatWindow/Input/index.tsx b/www/packages/docs-ui/src/components/AiAssistant/ChatWindow/Input/index.tsx index e77b934cb3..2786b17abf 100644 --- a/www/packages/docs-ui/src/components/AiAssistant/ChatWindow/Input/index.tsx +++ b/www/packages/docs-ui/src/components/AiAssistant/ChatWindow/Input/index.tsx @@ -80,7 +80,9 @@ export const AiAssistantChatWindowInput = ({ useEffect(() => { adjustTextareaHeight() - inputRef.current?.focus() + if (chatOpened) { + inputRef.current?.focus() + } }, [question]) const handleTouch = (e: React.TouchEvent) => { diff --git a/www/packages/docs-ui/src/providers/AiAssistant/index.tsx b/www/packages/docs-ui/src/providers/AiAssistant/index.tsx index df4841100e..e993c587cf 100644 --- a/www/packages/docs-ui/src/providers/AiAssistant/index.tsx +++ b/www/packages/docs-ui/src/providers/AiAssistant/index.tsx @@ -131,9 +131,11 @@ const AiAssistantInnerProvider = ({ useEffect(() => { setOnCompleteAction(() => { scrollToBottom() - inputRef.current?.focus({ - preventScroll: true, - }) + if (chatOpened) { + inputRef.current?.focus({ + preventScroll: true, + }) + } }) }, [scrollToBottom])