Merge pull request #6109 from B0sh/fix/ime-fix

fix: Prevent accidental message submitting on ChatInput for IME users
This commit is contained in:
Louis 2025-08-11 11:40:41 +07:00 committed by GitHub
commit 3fc85c59e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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)