From 93e4a04ef1407106e8c7e47c103d40be72ceb51e Mon Sep 17 00:00:00 2001 From: Emt-lin <41323133+Emt-lin@users.noreply.github.com> Date: Tue, 22 Apr 2025 07:13:47 +0800 Subject: [PATCH] fix: Add a new line when press the Enter key on mobile. (#1450) --- src/components/chat-components/ChatInput.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/chat-components/ChatInput.tsx b/src/components/chat-components/ChatInput.tsx index f77d5313..ccd7e262 100644 --- a/src/components/chat-components/ChatInput.tsx +++ b/src/components/chat-components/ChatInput.tsx @@ -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