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().
This commit is contained in:
@@ -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({
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={async () => {
|
||||
if (!quickReplyText.trim() || !onQuickReply) return;
|
||||
|
||||
setIsSendingQuickReply(true);
|
||||
try {
|
||||
await onQuickReply(quickReplyText);
|
||||
setQuickReplyText("");
|
||||
setIsQuickReplyFocused(false);
|
||||
} catch (error) {
|
||||
console.error("Failed to send quick reply:", error);
|
||||
} finally {
|
||||
setIsSendingQuickReply(false);
|
||||
}
|
||||
}}
|
||||
onClick={handleSendQuickReply}
|
||||
disabled={!quickReplyText.trim() || isSendingQuickReply}
|
||||
>
|
||||
{isSendingQuickReply ? (
|
||||
|
||||
Reference in New Issue
Block a user