From 4eb0d3b073ec5998e30284b1864187fdfaaa1f40 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Fri, 2 May 2025 23:22:26 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Enhance=20form=20submission?= =?UTF-8?q?=20for=20touch=20screens?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Chat/Input/ChatForm.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/client/src/components/Chat/Input/ChatForm.tsx b/client/src/components/Chat/Input/ChatForm.tsx index 2570d213c6..d878e7f07f 100644 --- a/client/src/components/Chat/Input/ChatForm.tsx +++ b/client/src/components/Chat/Input/ChatForm.tsx @@ -126,6 +126,16 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => { }); const { submitMessage, submitPrompt } = useSubmitMessage(); + + const isTouchScreen = useMemo(() => window.matchMedia?.('(pointer: coarse)').matches, []); + + const onSubmit = methods.handleSubmit((data: { text: string }) => { + submitMessage(data); + if (isTouchScreen) { + textAreaRef.current?.blur(); + } + }); + const handleKeyUp = useHandleKeyUp({ index, textAreaRef, @@ -199,7 +209,7 @@ const ChatForm = memo(({ index = 0 }: { index?: number }) => { return (