From f291480565807cd091673ce88e79a1a0ea715cf4 Mon Sep 17 00:00:00 2001 From: Shuki Vaknin Date: Fri, 3 Jul 2026 20:18:30 +0300 Subject: [PATCH] feat(email): send quick reply with Ctrl/Cmd+Enter The message-viewer quick-reply box only sent via the Send button. Add a keyboard shortcut (Ctrl+Enter / Cmd+Enter) mirroring the composer (#344), so a reply can be fired without reaching for the mouse. preventDefault stops the newline; the shortcut and button share one handleSendQuickReply(). --- components/email/email-viewer.tsx | 34 ++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/components/email/email-viewer.tsx b/components/email/email-viewer.tsx index 03386e94..ccc7b778 100644 --- a/components/email/email-viewer.tsx +++ b/components/email/email-viewer.tsx @@ -752,6 +752,19 @@ export function EmailViewer({ const [quickReplyText, setQuickReplyText] = useState(""); const [isQuickReplyFocused, setIsQuickReplyFocused] = useState(false); const [isSendingQuickReply, setIsSendingQuickReply] = useState(false); + const handleSendQuickReply = async () => { + if (!quickReplyText.trim() || !onQuickReply || isSendingQuickReply) return; + setIsSendingQuickReply(true); + try { + await onQuickReply(quickReplyText); + setQuickReplyText(""); + setIsQuickReplyFocused(false); + } catch (error) { + console.error("Failed to send quick reply:", error); + } finally { + setIsSendingQuickReply(false); + } + }; const [showSourceModal, setShowSourceModal] = useState(false); const [moreMenuOpen, setMoreMenuOpen] = useState(false); const [moreMenuSub, setMoreMenuSub] = useState<'move' | 'tag' | null>(null); @@ -4713,6 +4726,12 @@ export function EmailViewer({ value={quickReplyText} onChange={(e) => setQuickReplyText(e.target.value)} onFocus={() => setIsQuickReplyFocused(true)} + onKeyDown={(e) => { + if ((e.metaKey || e.ctrlKey) && e.key === "Enter") { + e.preventDefault(); + void handleSendQuickReply(); + } + }} placeholder={t('quick_reply_placeholder')} className={cn( "w-full px-3 py-2 text-sm border border-border bg-background text-foreground rounded-lg", @@ -4757,20 +4776,7 @@ export function EmailViewer({