Skip to content

Commit

Permalink
🪲 fix(useTextarea): enterToSend bugs (#2988)
Browse files Browse the repository at this point in the history
Co-authored-by: Danny Avila <danny@librechat.ai>
  • Loading branch information
berry-13 and danny-avila authored Jun 15, 2024
1 parent 97d12d0 commit 68bf7ac
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client/src/hooks/Input/useTextarea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default function useTextarea({
}

const isNonShiftEnter = e.key === 'Enter' && !e.shiftKey;
const isCtrlEnter = e.key === 'Enter' && e.ctrlKey;

if (isNonShiftEnter && filesLoading) {
e.preventDefault();
Expand All @@ -172,13 +173,14 @@ export default function useTextarea({
e.preventDefault();
}

if (e.key === 'Enter' && !enterToSend && textAreaRef.current) {
if (e.key === 'Enter' && !enterToSend && !isCtrlEnter && textAreaRef.current) {
e.preventDefault();
insertTextAtCursor(textAreaRef.current, '\n');
forceResize(textAreaRef);
return;
}

if (isNonShiftEnter && !isComposing?.current) {
if ((isNonShiftEnter || isCtrlEnter) && !isComposing?.current) {
const globalAudio = document.getElementById(globalAudioId) as HTMLAudioElement;
if (globalAudio) {
console.log('Unmuting global audio');
Expand Down

0 comments on commit 68bf7ac

Please sign in to comment.