fix: Add a new line when press the Enter key on mobile. (#1450)

This commit is contained in:
Emt-lin 2025-04-22 07:13:47 +08:00 committed by GitHub
parent 3c65d79a74
commit 93e4a04ef1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -253,10 +253,14 @@ const ChatInput = forwardRef<{ focus: () => void }, ChatInputProps>(
}
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
onSendMessage(false);
setHistoryIndex(-1);
setTempInput("");
// Only prevent default and send message on non-mobile platforms
if (!Platform.isMobile) {
e.preventDefault();
onSendMessage(false);
setHistoryIndex(-1);
setTempInput("");
}
// On mobile, do nothing here, allowing the default newline behavior
} else if (e.key === "ArrowUp") {
if (currentLineIndex > 0 || selectionStart > 0) {
// Allow normal cursor movement within multi-line input