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) {
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();
}
}
};