fix: Prevent accidental message submitting on ChatInput for users with IME input languages

This commit is contained in:
B0sh 2025-08-09 11:17:02 -05:00
parent 0cfc745954
commit 9b8fb62790

View File

@ -371,7 +371,9 @@ const ChatInput = ({ model, className, initialMessage }: ChatInputProps) => {
setRows(Math.min(newRows, maxRows))
}}
onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey && prompt.trim()) {
// e.keyCode 229 is for IME input with Safari
const isComposing = e.nativeEvent.isComposing || e.keyCode === 229;
if (e.key === 'Enter' && !e.shiftKey && prompt.trim() && !isComposing) {
e.preventDefault()
// Submit the message when Enter is pressed without Shift
handleSendMesage(prompt)