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.
This commit is contained in:
Shuki Vaknin
2026-06-24 02:23:57 +02:00
committed by Linus Rath
parent 3dd596ba50
commit d671c606a1
+9 -1
View File
@@ -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}