From 0fd83203cffdc07c534a21e41d6d8d93e5ea512e Mon Sep 17 00:00:00 2001 From: dealerweb Date: Thu, 20 Aug 2026 13:12:06 +0200 Subject: [PATCH] fix: clear the viewer when sending destroys the displayed draft Sending an edited draft destroys it server-side, but the viewer kept rendering the deleted message after the composer closed: the mailbox list refreshed (row gone, counter down) while selectedEmail still pointed at the destroyed draft. Clear the selection like a delete does - and return to the list on mobile - when the email on display is the draft the compose session was opened from or its latest autosaved successor (autosave replaces the draft under a fresh id on every save, so matching the sent draftId alone would miss). --- components/mail/mail-app.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/mail/mail-app.tsx b/components/mail/mail-app.tsx index 85b7036bf..9bcb4ccb0 100644 --- a/components/mail/mail-app.tsx +++ b/components/mail/mail-app.tsx @@ -1537,6 +1537,15 @@ export function MailApp({ linkSegments }: MailAppProps = {}) { const result = await sendEmail(sendClient, data.to, data.subject, data.body, data.cc, data.bcc, data.identityId, data.fromEmail, data.draftId, data.fromName, data.htmlBody, data.attachments, data.inReplyTo, data.references, data.delayedUntil, data.envelopeMailFrom, { requestReadReceipt: data.requestReadReceipt, localAccountId: data.localAccountId }); submitted = true; setShowComposer(false); + // Sending an edited draft destroys it server-side - and every autosave + // before that already replaced it under a fresh id (createDraft is a + // destroy+create). If the email on display is the draft this session + // was opened from, or its latest autosaved successor, clear the + // selection like a delete does. + if (selectedEmail && (selectedEmail.id === data.draftId || selectedEmail.id === pendingDraft?.draftId)) { + selectEmail(null); + if (isMobile) setActiveView('list'); + } if (result.filingError) { // The mail went out, but a post-send step (filing to Sent / // removing the old draft) was rejected - warn instead of staying