fix: prevent send message when empty message (#5109)
This commit is contained in:
parent
0fbc4a4664
commit
e312913088
@ -73,6 +73,9 @@ const ChatInput = ({
|
|||||||
setMessage('Please select a model to start chatting.')
|
setMessage('Please select a model to start chatting.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!prompt.trim()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
setMessage('')
|
setMessage('')
|
||||||
sendMessage(prompt)
|
sendMessage(prompt)
|
||||||
}
|
}
|
||||||
@ -351,7 +354,7 @@ const ChatInput = ({
|
|||||||
setRows(Math.min(newRows, maxRows))
|
setRows(Math.min(newRows, maxRows))
|
||||||
}}
|
}}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
if (e.key === 'Enter' && !e.shiftKey && prompt) {
|
if (e.key === 'Enter' && !e.shiftKey && prompt.trim()) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
// Submit the message when Enter is pressed without Shift
|
// Submit the message when Enter is pressed without Shift
|
||||||
handleSendMesage(prompt)
|
handleSendMesage(prompt)
|
||||||
@ -463,9 +466,9 @@ const ChatInput = ({
|
|||||||
</Button>
|
</Button>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
variant={!prompt ? null : 'default'}
|
variant={!prompt.trim() ? null : 'default'}
|
||||||
size="icon"
|
size="icon"
|
||||||
disabled={!prompt}
|
disabled={!prompt.trim()}
|
||||||
onClick={() => handleSendMesage(prompt)}
|
onClick={() => handleSendMesage(prompt)}
|
||||||
>
|
>
|
||||||
{streamingContent ? (
|
{streamingContent ? (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user