Skip to content

Commit 152aa5e

Browse files
committed
content: Remove TextStyle merge in rendering unicode emoji
Fixes zulip#1818. The InlineContent widget creates a Text.rich with a tree of `InlineSpan`s, and the widget's `style` param is passed to the root span in that tree. That style's attributes will propagate down the tree as defaults, which means that a non-root node will still be styled with e.g. h1 font size if it doesn't `TextStyle.merge` that root style into its own style, as was happening here. That merging can also be unhelpful, not just unnecessary, because it can clobber attributes that were set at nodes between the current node and the root. This kind of clobbering causes some known issues; the first of these is fixed in this commit, and we'll fix the rest, coming up: - zulip#1818 content: Unicode emoji in strikethrough should have strikethrough line, but doesn't - zulip#1817 content: Bold text in strikethrough should have strikethrough line, but doesn't - zulip#1812 content: Inline code in a bold span should be bold (but isn't) - zulip#806 content: Inline code links should be rendered with the link color We'll fix the others, coming up.
1 parent d41dd5b commit 152aa5e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/widgets/content.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,7 @@ class _InlineContentBuilder {
11271127

11281128
case UnicodeEmojiNode():
11291129
return TextSpan(text: node.emojiUnicode, recognizer: _recognizer,
1130-
style: widget.style
1131-
.merge(ContentTheme.of(_context!).textStyleEmoji));
1130+
style: ContentTheme.of(_context!).textStyleEmoji);
11321131

11331132
case ImageEmojiNode():
11341133
return WidgetSpan(alignment: PlaceholderAlignment.middle,

test/widgets/content_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,14 @@ void main() {
982982
_ => throw StateError('unexpected platform in test'),
983983
});
984984
}, variant: const TargetPlatformVariant({TargetPlatform.android, TargetPlatform.iOS}));
985+
986+
testWidgets('has strike-through line in strike-through', (tester) async {
987+
// Regression test for https://github.com/zulip/zulip-flutter/issues/1818
988+
await prepareContent(tester,
989+
plainContent('<p><del>foo<span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span>bar</del></p>'));
990+
final style = mergedStyleOf(tester, '\u{1f44d}');
991+
check(style!.decoration).equals(TextDecoration.lineThrough);
992+
});
985993
});
986994

987995
group('inline math', () {

0 commit comments

Comments
 (0)