fix: prevent send message when empty message (#5109)

This commit is contained in:
Faisal Amir 2025-05-27 09:33:51 +07:00 committed by GitHub
parent 0fbc4a4664
commit e312913088
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,6 +73,9 @@ const ChatInput = ({
setMessage('Please select a model to start chatting.')
return
}
if (!prompt.trim()) {
return
}
setMessage('')
sendMessage(prompt)
}
@ -351,7 +354,7 @@ const ChatInput = ({
setRows(Math.min(newRows, maxRows))
}}
onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey && prompt) {
if (e.key === 'Enter' && !e.shiftKey && prompt.trim()) {
e.preventDefault()
// Submit the message when Enter is pressed without Shift
handleSendMesage(prompt)
@ -463,9 +466,9 @@ const ChatInput = ({
</Button>
) : (
<Button
variant={!prompt ? null : 'default'}
variant={!prompt.trim() ? null : 'default'}
size="icon"
disabled={!prompt}
disabled={!prompt.trim()}
onClick={() => handleSendMesage(prompt)}
>
{streamingContent ? (