From d671c606a158f3e6e8d8ef1c8377eb79c4f7c373 Mon Sep 17 00:00:00 2001 From: Shuki Vaknin Date: Tue, 23 Jun 2026 17:40:27 +0300 Subject: [PATCH] feat(mail): deleting the open message returns to the list, not the next email Deleting from inside an open message advanced to the next email. Gmail (and most clients) return you to the message list instead. In the viewer's onDelete, deselect first (handleMobileBack) so the store's remove-and-advance sees no selection and won't auto-open the next message, then delete the captured email. Returning to the list immediately also avoids a flash of the next email. Scoped to the single-message viewer; list and keyboard deletes (which keep auto-advance) are unchanged. Consistent with the mark-unread-returns-to-list behaviour. --- app/(main)/[locale]/page.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/(main)/[locale]/page.tsx b/app/(main)/[locale]/page.tsx index 1edd0997..f7896154 100644 --- a/app/(main)/[locale]/page.tsx +++ b/app/(main)/[locale]/page.tsx @@ -3099,7 +3099,15 @@ export default function Home() { onReply={handleReply} onReplyAll={handleReplyAll} onForward={handleForward} - onDelete={() => handleDelete()} + onDelete={() => { + // Deleting the open message returns to the list (Gmail-style), + // not the next email. Deselect first so the store's + // remove-and-advance sees no selection and doesn't auto-open + // the next message; then delete the captured email. + const target = selectedEmail; + handleMobileBack(); + handleDelete(target); + }} onArchive={() => handleArchive()} onToggleStar={handleToggleStar} onSetColorTag={handleSetColorTag}