fix(web): chat input add composition

This commit is contained in:
zhaoying
2026-04-08 21:21:09 +08:00
parent bad6087c25
commit 6bb01119d0

View File

@@ -27,6 +27,7 @@ const ChatInput: FC<ChatInputProps> = ({
}) => {
const [inputValue, setInputValue] = useState('')
const [isFocus, setIsFocus] = useState(false)
const [isComposing, setIsComposing] = useState(false)
// Clear input when external message is cleared
useEffect(() => {
@@ -78,9 +79,11 @@ const ChatInput: FC<ChatInputProps> = ({
setInputValue(e.target.value)
onChange?.(e.target.value)
}}
onCompositionStart={() => setIsComposing(true)}
onCompositionEnd={() => setIsComposing(false)}
onKeyDown={(e) => {
// Enter to send, Shift+Enter for new line
if (e.key === 'Enter' && !e.shiftKey && (e.target as HTMLTextAreaElement).value?.trim() !== '' && !loading) {
if (e.key === 'Enter' && !e.shiftKey && !isComposing && (e.target as HTMLTextAreaElement).value?.trim() !== '' && !loading) {
e.preventDefault();
handleSend();
}