From 1d88a8629393785831b1ba98e93886e4d64b9c0c Mon Sep 17 00:00:00 2001 From: Jing Hua Date: Thu, 29 Jun 2023 23:16:32 -0700 Subject: [PATCH] consistent enter to submit for new and edit message fixes #255, fixes #379 --- .../ChatContent/Message/View/EditView.tsx | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/components/Chat/ChatContent/Message/View/EditView.tsx b/src/components/Chat/ChatContent/Message/View/EditView.tsx index 3427923..9b91791 100644 --- a/src/components/Chat/ChatContent/Message/View/EditView.tsx +++ b/src/components/Chat/ChatContent/Message/View/EditView.tsx @@ -43,21 +43,22 @@ const EditView = ({ if (e.key === 'Enter' && !isMobile && !e.nativeEvent.isComposing) { const enterToSubmit = useStore.getState().enterToSubmit; - if (sticky) { - if ( - (enterToSubmit && !e.shiftKey) || - (!enterToSubmit && (e.ctrlKey || e.shiftKey)) - ) { + + if (e.ctrlKey && e.shiftKey) { + e.preventDefault(); + handleSaveAndSubmit(); + resetTextAreaHeight(); + } else if ( + (enterToSubmit && !e.shiftKey) || + (!enterToSubmit && (e.ctrlKey || e.shiftKey)) + ) { + if (sticky) { e.preventDefault(); handleSaveAndSubmit(); resetTextAreaHeight(); + } else { + handleSave(); } - } else { - if (e.ctrlKey && e.shiftKey) { - e.preventDefault(); - handleSaveAndSubmit(); - resetTextAreaHeight(); - } else if (e.ctrlKey || e.shiftKey) handleSave(); } } };