fix(composer): correct recipient expand button web/native branching

The expand-button condition mis-expanded the web check, so the compact
chevron could render alongside the inline prefix buttons on the web path.
Rewrite it as the exact complement of the inline-buttons gate
(isMobileResponsive || !_isWeb), keeping the two recipient-add
affordances mutually exclusive while still showing the chevron on native
tablet.

Add widget tests for the native-mobile, web-wide, native-tablet and
narrow-web (web-responsive) branches.

(cherry picked from commit b503de2278)
This commit is contained in:
Dat H. Pham authored and Dat H. Pham committed 2026-08-19 15:22:34 +07:00
1 parent b546ab0347
commit c70a4e943f
2 files changed
+46 -8

No files matched your search

@@ -416,10 +416,10 @@ class _RecipientComposerWidgetState extends State<RecipientComposerWidget> {
_ => false,
};
// Native platforms (mobile + tablet) always use the compact expand button;
// the inline prefix buttons are a web-only, wide-screen affordance.
return shouldCheckPrefix &&
(isMobileResponsive || !PlatformInfo.isWeb || widget.isTestingForWeb);
// The compact expand button is the exact complement of the inline prefix
// buttons (`_isWeb && !isMobileResponsive`): it shows on native platforms
// (mobile + tablet) or on a narrow web window.
return shouldCheckPrefix && (isMobileResponsive || !_isWeb);
}
Widget _buildExpandButton() {
@@ -464,6 +464,7 @@ void main() {
EmailAddress('test1', 'test1@example.com'),
];
// Native mobile (no isTestingForWeb): compact expand button, no inline buttons.
final widget = makeTestableWidget(
child: RecipientComposerWidget(
prefix: prefix,
@@ -472,7 +473,6 @@ void main() {
imagePaths: imagePaths,
maxWidth: 360,
keyTagEditor: keyEmailTagEditor,
isTestingForWeb: true,
toState: PrefixRecipientState.enabled,
),
);
@@ -557,13 +557,13 @@ void main() {
expect(recipientFromButtonFinder, findsOneWidget);
expect(recipientCcButtonFinder, findsOneWidget);
expect(recipientBccButtonFinder, findsOneWidget);
// Web wide is inline-only: the compact expand button must NOT also render
// (guards mutual exclusivity between the two recipient-add affordances).
expect(find.byKey(Key('prefix_${prefix.name}_recipient_expand_button')), findsNothing);
});
testWidgets('WHEN on a native (non-web) tablet-width screen (>= 600)\n'
'To field SHOULD show the expand chevron (same as mobile) and NO inline Cc/Bcc buttons', (tester) async {
// Simulate an iPad/tablet-width native screen: no isTestingForWeb, so
// PlatformInfo.isWeb == false. Regression guard for the bug where native
// tablet rendered neither the inline buttons nor the expand chevron.
tester.view.physicalSize = const Size(1024, 768);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
@@ -596,5 +596,43 @@ void main() {
expect(recipientCcButtonFinder, findsNothing);
expect(recipientBccButtonFinder, findsNothing);
});
testWidgets('WHEN on web with a narrow (< 600) window (web-responsive)\n'
'To field SHOULD show the expand chevron and NO inline Cc/Bcc buttons', (tester) async {
// Simulate web (isTestingForWeb) at a phone-width window: the inline
// buttons collapse to the compact expand chevron, same as mobile.
tester.view.physicalSize = const Size(400, 800);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final listEmailAddress = <EmailAddress>[
EmailAddress('test1', 'test1@example.com'),
];
final widget = makeTestableWidget(
child: RecipientComposerWidget(
prefix: prefix,
prefixRootState: prefix,
listEmailAddress: listEmailAddress,
imagePaths: imagePaths,
maxWidth: 360,
keyTagEditor: keyEmailTagEditor,
isTestingForWeb: true,
toState: PrefixRecipientState.enabled,
),
);
await tester.pumpWidget(widget);
await tester.pumpAndSettle();
final recipientExpandButtonFinder = find.byKey(Key('prefix_${prefix.name}_recipient_expand_button'));
final recipientCcButtonFinder = find.byKey(Key('prefix_${prefix.name}_recipient_cc_button'));
final recipientBccButtonFinder = find.byKey(Key('prefix_${prefix.name}_recipient_bcc_button'));
expect(recipientExpandButtonFinder, findsOneWidget);
expect(recipientCcButtonFinder, findsNothing);
expect(recipientBccButtonFinder, findsNothing);
});
});
}