Skip to content

Commit

Permalink
fix: Do not submit with Shift + Enter
Browse files Browse the repository at this point in the history
  • Loading branch information
tiero committed Nov 9, 2023
1 parent 1a8e747 commit 46910d6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/modules/prem-chat/components/PremChatContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ const PremChatContainer = ({
}, [abort, historyId]);

const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter") {
e.preventDefault();
onSubmit(e);
// Check for 'Enter' key without 'Shift'
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault(); // Prevents new line from being added
onSubmit(e); // Calls your submit function
}
// If 'Shift' + 'Enter' is pressed, let the default behavior occur, which is to add a new line
};

return (
Expand Down

0 comments on commit 46910d6

Please sign in to comment.