Skip to content

Commit

Permalink
consistent enter to submit for new and edit message
Browse files Browse the repository at this point in the history
fixes ztjhz#255, fixes ztjhz#379
  • Loading branch information
ztjhz committed Jun 30, 2023
1 parent c7a355b commit 1d88a86
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/components/Chat/ChatContent/Message/View/EditView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
};
Expand Down

0 comments on commit 1d88a86

Please sign in to comment.