diff --git a/components/email/email-composer.tsx b/components/email/email-composer.tsx index f15d681f..4014b937 100644 --- a/components/email/email-composer.tsx +++ b/components/email/email-composer.tsx @@ -1285,6 +1285,40 @@ export function EmailComposer({ } }; + const handleComposerKeyDown = (e: React.KeyboardEvent) => { + if (e.defaultPrevented) return; + + const isPlainEscape = e.key === 'Escape' && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey; + const isSendShortcut = e.key === 'Enter' && e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey; + if (!isPlainEscape && !isSendShortcut) return; + + if ( + showTemplatePicker || + showSaveAsTemplate || + showScheduleDialog || + smimePassphrasePrompt || + showAttachmentWarning || + showCloseDialog + ) return; + + if (isPlainEscape) { + if (activeAutoField) return; + e.preventDefault(); + handleClose(); + return; + } + + if (isSendShortcut) { + if (e.repeat) { + e.preventDefault(); + return; + } + + e.preventDefault(); + handleSend(); + } + }; + return (
{/* Drag overlay */} {isDraggingOver && (