From a4132a8487a7d88f56ac9793cab90d7bd1bf9575 Mon Sep 17 00:00:00 2001 From: Madison Date: Wed, 2 Jul 2025 16:21:02 -0500 Subject: [PATCH] fix useChat for input of text --- docs/src/components/chat/ai-chat.tsx | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/docs/src/components/chat/ai-chat.tsx b/docs/src/components/chat/ai-chat.tsx index d029fdc35..f19d5129c 100644 --- a/docs/src/components/chat/ai-chat.tsx +++ b/docs/src/components/chat/ai-chat.tsx @@ -106,7 +106,6 @@ export function useChatContext() { function AIChatDrawer() { const { isOpen, isExpanded, toggleChat, expandChat, collapseChat } = useChatContext(); - const [input, setInput] = useState(''); const [docsContent, setDocsContent] = useState(''); // Fetch documentation content when component mounts @@ -136,6 +135,8 @@ function AIChatDrawer() { const { messages, + input, + handleInputChange, handleSubmit, isLoading, error, @@ -150,22 +151,6 @@ function AIChatDrawer() { }, }); - const handleFormSubmit = (e: React.FormEvent) => { - e.preventDefault(); - if (!input.trim() || isLoading) return; - - handleSubmit(e, { - body: { - docsContent, - }, - }); - setInput(''); - }; - - const handleInputChange = (e: React.ChangeEvent) => { - setInput(e.target.value); - }; - // Starter prompts for users const starterPrompts = [ { @@ -186,7 +171,8 @@ function AIChatDrawer() { ]; const handleStarterPromptClick = (prompt: string) => { - setInput(prompt); + // Use the handleInputChange from useChat to update the input + handleInputChange({ target: { value: prompt } } as React.ChangeEvent); }; return ( @@ -303,7 +289,7 @@ function AIChatDrawer() { {/* Input */}
-
+