From bddf29c6048f67dcf254212e357ab2f08a3a28ae Mon Sep 17 00:00:00 2001 From: dab246 Date: Fri, 10 Oct 2025 15:28:23 +0700 Subject: [PATCH] hotfix: Do not add `Reply-To` to recipients field collapsed when unfocus (cherry picked from commit aa0c27ce1c9d7fdd579d0f25c6b7d8f4b50adf70) --- .../presentation/composer_controller.dart | 22 ++++------- .../composer/presentation/composer_view.dart | 4 +- .../presentation/composer_view_web.dart | 6 +-- ...andle_recipients_collapsed_extensions.dart | 39 +++++++++++++++---- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/lib/features/composer/presentation/composer_controller.dart b/lib/features/composer/presentation/composer_controller.dart index d1ec38363..e76b60349 100644 --- a/lib/features/composer/presentation/composer_controller.dart +++ b/lib/features/composer/presentation/composer_controller.dart @@ -599,9 +599,7 @@ class ComposerController extends BaseController richTextMobileTabletController?.richTextController.hideRichTextView(); } autoCreateEmailTag(); - if (isRecipientsNotEmpty) { - hideAllRecipients(); - } + triggerHideRecipientsFiledsWhenUnfocus(); } } @@ -720,8 +718,8 @@ class ComposerController extends BaseController listBccEmailAddress = List.from(recipients.bcc); listReplyToEmailAddress = List.from(recipients.replyTo); - if (isRecipientsNotEmpty) { - hideAllRecipients(); + if (isRecipientsWithoutReplyToNotEmpty) { + hideAllRecipientsFields(); isInitialRecipient.value = true; } else { toRecipientState.value = PrefixRecipientState.enabled; @@ -792,7 +790,7 @@ class ComposerController extends BaseController return; } - if (listEmailAddressInvalid.isNotEmpty) { + if (existEmailAddressInvalid) { MessageDialogActionManager().showConfirmDialogAction(context, appLocalizations.message_dialog_send_email_with_email_address_invalid, appLocalizations.fix_email_addresses, @@ -1440,9 +1438,7 @@ class ComposerController extends BaseController void clickOutsideComposer(BuildContext context) { clearFocus(context); - if (isRecipientsNotEmpty) { - hideAllRecipients(); - } + triggerHideRecipientsFiledsWhenUnfocus(); } void _closeComposerAction({dynamic result, bool closeOverlays = false}) { @@ -1712,9 +1708,7 @@ class ComposerController extends BaseController richTextMobileTabletController?.richTextController.showDeviceKeyboard); } autoCreateEmailTag(); - if (isRecipientsNotEmpty) { - hideAllRecipients(); - } + triggerHideRecipientsFiledsWhenUnfocus(); } void _onChangeCursorOnMobile(List? coordinates, BuildContext context) { @@ -1846,9 +1840,7 @@ class ComposerController extends BaseController popBack(); } autoCreateEmailTag(); - if (isRecipientsNotEmpty) { - hideAllRecipients(); - } + triggerHideRecipientsFiledsWhenUnfocus(); } FocusNode? getNextFocusOfToEmailAddress() { diff --git a/lib/features/composer/presentation/composer_view.dart b/lib/features/composer/presentation/composer_view.dart index 638c26c18..9307dc6e3 100644 --- a/lib/features/composer/presentation/composer_view.dart +++ b/lib/features/composer/presentation/composer_view.dart @@ -128,7 +128,7 @@ class ComposerView extends GetWidget { Obx(() { if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled) { return RecipientsCollapsedComposerWidget( - listEmailAddress: controller.allListEmailAddress, + listEmailAddress: controller.allListEmailAddressWithoutReplyTo, margin: ComposerStyle.mobileRecipientMargin, onShowAllRecipientsAction: controller.showFullRecipients, ); @@ -307,7 +307,7 @@ class ComposerView extends GetWidget { Obx(() { if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled) { return RecipientsCollapsedComposerWidget( - listEmailAddress: controller.allListEmailAddress, + listEmailAddress: controller.allListEmailAddressWithoutReplyTo, margin: ComposerStyle.mobileRecipientMargin, onShowAllRecipientsAction: controller.showFullRecipients, ); diff --git a/lib/features/composer/presentation/composer_view_web.dart b/lib/features/composer/presentation/composer_view_web.dart index 573dccfc4..dab64e3d9 100644 --- a/lib/features/composer/presentation/composer_view_web.dart +++ b/lib/features/composer/presentation/composer_view_web.dart @@ -122,7 +122,7 @@ class ComposerView extends GetWidget { ), if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled) RecipientsCollapsedComposerWidget( - listEmailAddress: controller.allListEmailAddress, + listEmailAddress: controller.allListEmailAddressWithoutReplyTo, margin: ComposerStyle.mobileRecipientMargin, onShowAllRecipientsAction: controller.showFullRecipients, ), @@ -349,7 +349,7 @@ class ComposerView extends GetWidget { ), if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled) RecipientsCollapsedComposerWidget( - listEmailAddress: controller.allListEmailAddress, + listEmailAddress: controller.allListEmailAddressWithoutReplyTo, margin: ComposerStyle.desktopRecipientMargin, onShowAllRecipientsAction: controller.showFullRecipients, ), @@ -617,7 +617,7 @@ class ComposerView extends GetWidget { ), if (controller.recipientsCollapsedState.value == PrefixRecipientState.enabled) RecipientsCollapsedComposerWidget( - listEmailAddress: controller.allListEmailAddress, + listEmailAddress: controller.allListEmailAddressWithoutReplyTo, margin: ComposerStyle.desktopRecipientMargin, onShowAllRecipientsAction: controller.showFullRecipients, ), diff --git a/lib/features/composer/presentation/extensions/handle_recipients_collapsed_extensions.dart b/lib/features/composer/presentation/extensions/handle_recipients_collapsed_extensions.dart index 9bd32e8fb..dc5800c3e 100644 --- a/lib/features/composer/presentation/extensions/handle_recipients_collapsed_extensions.dart +++ b/lib/features/composer/presentation/extensions/handle_recipients_collapsed_extensions.dart @@ -12,17 +12,25 @@ extension HandleRecipientsCollapsedExtensions on ComposerController { listBccEmailAddress + listReplyToEmailAddress; - List get listEmailAddressInvalid => allListEmailAddress - .where( + List get allListEmailAddressWithoutReplyTo => + listToEmailAddress + + listCcEmailAddress + + listBccEmailAddress; + + bool get existEmailAddressInvalid => allListEmailAddress + .any( (emailAddress) => !EmailUtils.isEmailAddressValid( emailAddress.emailAddress, ), - ) - .toList(); + ); - bool get isRecipientsNotEmpty => listToEmailAddress.isNotEmpty || + bool get isRecipientsWithoutReplyToNotEmpty => listToEmailAddress.isNotEmpty || listCcEmailAddress.isNotEmpty || - listBccEmailAddress.isNotEmpty || + listBccEmailAddress.isNotEmpty; + + bool get isRecipientsEmptyExceptReplyTo => listToEmailAddress.isEmpty && + listCcEmailAddress.isEmpty && + listBccEmailAddress.isEmpty && listReplyToEmailAddress.isNotEmpty; void showFullRecipients() { @@ -90,7 +98,15 @@ extension HandleRecipientsCollapsedExtensions on ComposerController { } } - void hideAllRecipients() { + void triggerHideRecipientsFiledsWhenUnfocus() { + if (isRecipientsEmptyExceptReplyTo) { + hideAllRecipientsFieldsExceptTo(); + } else if (isRecipientsWithoutReplyToNotEmpty) { + hideAllRecipientsFields(); + } + } + + void hideAllRecipientsFields() { fromRecipientState.value = PrefixRecipientState.disabled; toRecipientState.value = PrefixRecipientState.disabled; ccRecipientState.value = PrefixRecipientState.disabled; @@ -98,4 +114,13 @@ extension HandleRecipientsCollapsedExtensions on ComposerController { replyToRecipientState.value = PrefixRecipientState.disabled; recipientsCollapsedState.value = PrefixRecipientState.enabled; } + + void hideAllRecipientsFieldsExceptTo() { + toRecipientState.value = PrefixRecipientState.enabled; + fromRecipientState.value = PrefixRecipientState.disabled; + ccRecipientState.value = PrefixRecipientState.disabled; + bccRecipientState.value = PrefixRecipientState.disabled; + replyToRecipientState.value = PrefixRecipientState.disabled; + recipientsCollapsedState.value = PrefixRecipientState.disabled; + } }