Add ESC keyboard shortcut to close email detail view

Adds the ability to close the email detail/thread detail view by pressing
the ESC key, following the same pattern used for closing the composer.

Changes:
- Add closeThreadDetail to MailViewActionShortcutType enum
- Map ESC key to closeThreadDetail in AppShortcutManager
- Handle closeThreadDetail action in HandleMailShortcutActionsExtension

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Martin Kask
2026-01-20 18:37:21 +02:00
committed by Dat H. Pham
parent ea7b9fed33
commit f78f78c659
3 changed files with 13 additions and 1 deletions
@@ -25,6 +25,8 @@ class AppShortcutManager {
return MailViewActionShortcutType.newMessage;
} else if (keysPressed.isOnly(LogicalKeyboardKey.keyU)) {
return MailViewActionShortcutType.markAsUnread;
} else if (keysPressed.isOnly(LogicalKeyboardKey.escape)) {
return MailViewActionShortcutType.closeThreadDetail;
} else {
return null;
}
@@ -9,7 +9,8 @@ enum MailViewActionShortcutType {
forward,
delete,
newMessage,
markAsUnread;
markAsUnread,
closeThreadDetail;
EmailActionType? getEmailActionType({
required PresentationEmail currentEmail,
@@ -34,6 +35,8 @@ enum MailViewActionShortcutType {
return EmailActionType.compose;
case MailViewActionShortcutType.markAsUnread:
return EmailActionType.markAsUnread;
case MailViewActionShortcutType.closeThreadDetail:
return null;
}
}
}
@@ -9,6 +9,7 @@ import 'package:rxdart/rxdart.dart';
import 'package:tmail_ui_user/features/base/shortcut/app_shortcut_manager.dart';
import 'package:tmail_ui_user/features/base/shortcut/mail/mail_view_action_shortcut_type.dart';
import 'package:tmail_ui_user/features/email/presentation/action/email_ui_action.dart';
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/close_thread_detail_action.dart';
import 'package:tmail_ui_user/features/thread_detail/presentation/extension/key_shortcut_extension.dart';
import 'package:tmail_ui_user/features/thread_detail/presentation/model/mail_view_shortcut_action_view_event.dart';
import 'package:tmail_ui_user/features/thread_detail/presentation/thread_detail_controller.dart';
@@ -64,6 +65,12 @@ extension HandleMailShortcutActionsExtension on ThreadDetailController {
void handleMailShortcutAction(MailViewActionShortcutType shortcutType) {
log('$runtimeType::handleMailShortcutAction:🔥ShortcutType: $shortcutType');
if (shortcutType == MailViewActionShortcutType.closeThreadDetail) {
closeThreadDetailAction();
return;
}
final expandedEmail = currentExpandedEmail;
if (expandedEmail == null) return;