From 68bf7ac7c01f6412c5b433991296680f7f673340 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sat, 15 Jun 2024 15:30:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=B2=20fix(useTextarea):=20enterToSend?= =?UTF-8?q?=20bugs=20(#2988)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Danny Avila --- client/src/hooks/Input/useTextarea.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/hooks/Input/useTextarea.ts b/client/src/hooks/Input/useTextarea.ts index 569766784c..5a56685ad5 100644 --- a/client/src/hooks/Input/useTextarea.ts +++ b/client/src/hooks/Input/useTextarea.ts @@ -163,6 +163,7 @@ export default function useTextarea({ } const isNonShiftEnter = e.key === 'Enter' && !e.shiftKey; + const isCtrlEnter = e.key === 'Enter' && e.ctrlKey; if (isNonShiftEnter && filesLoading) { e.preventDefault(); @@ -172,13 +173,14 @@ export default function useTextarea({ e.preventDefault(); } - if (e.key === 'Enter' && !enterToSend && textAreaRef.current) { + if (e.key === 'Enter' && !enterToSend && !isCtrlEnter && textAreaRef.current) { + e.preventDefault(); insertTextAtCursor(textAreaRef.current, '\n'); forceResize(textAreaRef); return; } - if (isNonShiftEnter && !isComposing?.current) { + if ((isNonShiftEnter || isCtrlEnter) && !isComposing?.current) { const globalAudio = document.getElementById(globalAudioId) as HTMLAudioElement; if (globalAudio) { console.log('Unmuting global audio');