consistent enter to submit for new and edit message

fixes #255, fixes #379
This commit is contained in:
Jing Hua 2023-06-29 23:16:32 -07:00
parent c7a355b407
commit 1d88a86293

View file

@ -43,21 +43,22 @@ const EditView = ({
if (e.key === 'Enter' && !isMobile && !e.nativeEvent.isComposing) { if (e.key === 'Enter' && !isMobile && !e.nativeEvent.isComposing) {
const enterToSubmit = useStore.getState().enterToSubmit; const enterToSubmit = useStore.getState().enterToSubmit;
if (sticky) {
if ( if (e.ctrlKey && e.shiftKey) {
(enterToSubmit && !e.shiftKey) || e.preventDefault();
(!enterToSubmit && (e.ctrlKey || e.shiftKey)) handleSaveAndSubmit();
) { resetTextAreaHeight();
} else if (
(enterToSubmit && !e.shiftKey) ||
(!enterToSubmit && (e.ctrlKey || e.shiftKey))
) {
if (sticky) {
e.preventDefault(); e.preventDefault();
handleSaveAndSubmit(); handleSaveAndSubmit();
resetTextAreaHeight(); resetTextAreaHeight();
} else {
handleSave();
} }
} else {
if (e.ctrlKey && e.shiftKey) {
e.preventDefault();
handleSaveAndSubmit();
resetTextAreaHeight();
} else if (e.ctrlKey || e.shiftKey) handleSave();
} }
} }
}; };