Skip to content

Commit 897737d

Browse files
Merge pull request #399 from microsoft/dev
fix: Chat Input Reset and Send Button Disable Logic in ChatRoom Component
2 parents 4fc4350 + c9ae76b commit 897737d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

App/frontend-app/src/components/chat/chatRoom.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
7373
});
7474
const [referencesForFeedbackForm, setReferencesForFeedbackForm] = useState<Reference[]>([]);
7575
const [textAreaValue, setTextAreaValue] = useState("");
76+
const [textareaKey, setTextareaKey] = useState(0);
7677
const inputRef = useRef<HTMLTextAreaElement>(null);
7778
const [allChunkTexts, setAllChunkTexts] = useState<string[]>([]);
7879

@@ -568,12 +569,15 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
568569
setSelectedDocument([]);
569570
setIsLoading(false);
570571
setChatSessionId(null);
572+
setTextAreaValue("");
573+
setTextareaKey(prev => prev + 1);
571574
}}
572575
>
573576
{t('components.chat.new-topic')}
574577
</Button>
575578

576579
<Textarea
580+
key={textareaKey}
577581
ref={inputRef}
578582
value={textAreaValue}
579583
className="!ml-4 max-h-48 w-full !max-w-none"
@@ -583,6 +587,7 @@ export function ChatRoom({ searchResultDocuments, selectedDocuments, chatWithDoc
583587
placeholder={t('components.chat.input-placeholder')}
584588
disabled={isLoading}
585589
onSubmit={handleSend}
590+
disableSend = {textAreaValue.trim().length === 0 || isLoading}
586591
contentAfter={undefined}
587592
/>
588593
</div>

0 commit comments

Comments
 (0)