Skip to content

Commit adeca3b

Browse files
committed
emoji: Fix picker item height scaling for text emoji.
When using the text-only emojis the emoji picker list items did not scale correctly with the system's text scale factor in the earlier pr . i think this was because the placeholder for the emoji glyph had a fixed, unscalable height, preventing the row from growing as we wanted. This new commit aims to fix the issue by replacing the null placeholder with a Text widget that correctly scales, ensuring the list item's height is consistent with the users accessibility settings. also a regression test is added to verify this behavior. Fixes #1587
1 parent 4c42364 commit adeca3b

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

lib/widgets/emoji_reaction.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,12 @@ class EmojiPickerListEntry extends StatelessWidget {
577577

578578
// TODO deduplicate this logic with [_EmojiAutocompleteItem]
579579
final emojiDisplay = emoji.emojiDisplay.resolve(store.userSettings);
580-
final Widget? glyph = switch (emojiDisplay) {
580+
final Widget glyph = switch (emojiDisplay) {
581581
ImageEmojiDisplay() =>
582582
ImageEmojiWidget(size: _emojiSize, emojiDisplay: emojiDisplay),
583583
UnicodeEmojiDisplay() =>
584584
UnicodeEmojiWidget(size: _emojiSize, emojiDisplay: emojiDisplay),
585-
TextEmojiDisplay() => null, // The text is already shown separately.
585+
TextEmojiDisplay() => Text(' ', style: TextStyle(fontSize: _emojiSize)),
586586
};
587587

588588
final label = emoji.aliases.isEmpty
@@ -601,7 +601,7 @@ class EmojiPickerListEntry extends StatelessWidget {
601601
child: Row(spacing: 4, children: [
602602
Padding(
603603
padding: const EdgeInsets.all(10),
604-
child: glyph ?? SizedBox(width: _emojiSize, height: _emojiSize)),
604+
child: glyph),
605605
Flexible(child: Text(label,
606606
maxLines: 2,
607607
overflow: TextOverflow.ellipsis,

test/widgets/emoji_reaction_test.dart

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,42 @@ void main() {
555555

556556
debugNetworkImageHttpClientProvider = null;
557557
});
558+
testWidgets('text emoji list items must have correct height', (tester) async {
559+
// Regression test for #1587
560+
tester.platformDispatcher.textScaleFactorTestValue = 2.0;
561+
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
558562

563+
final message = eg.streamMessage();
564+
// Firstly, set up the initial emoji picker. This leaves it open.
565+
await setupEmojiPicker(tester, message: message, narrow: TopicNarrow.ofMessage(message));
566+
567+
// and Now, change the setting to text-only emoji.
568+
await store.handleEvent(UserSettingsUpdateEvent(id: 1,
569+
property: UserSettingName.emojiset,
570+
value: Emojiset.text));
571+
572+
// Close the emoji picker. This also closes the underlying action sheet also.
573+
Navigator.of(tester.element(find.byType(EmojiPicker))).pop();
574+
await tester.pumpAndSettle(); // Let dismiss animations finish.
575+
576+
// We are now back at the message list. Let's start over to see the setting change.
577+
// now we Long-press the message to open the action sheet again.
578+
await tester.longPress(find.byType(MessageContent));
579+
await tester.pumpAndSettle();
580+
581+
// now we Tap the button to open the emoji picker, which will now use the new setting.
582+
await tester.tap(find.byIcon(ZulipIcons.chevron_right));
583+
await tester.pumpAndSettle();
584+
585+
// Finally, find a list entry and check its height.
586+
final listEntryFinder = find.byType(EmojiPickerListEntry).first;
587+
await tester.ensureVisible(listEntryFinder);
588+
589+
final renderBox = tester.renderObject<RenderBox>(listEntryFinder);
590+
check(renderBox.size.height).isGreaterThan(48.0);
591+
592+
debugNetworkImageHttpClientProvider = null;
593+
});
559594
testWidgets('with bottom view padding', (tester) async {
560595
await prepare(tester, viewPadding: FakeViewPadding(bottom: 10));
561596

0 commit comments

Comments
 (0)