Skip to content

Commit c0d82e1

Browse files
committed
content: Remove TextStyle merge in rendering bold spans
Fixes zulip#1817. Similar reasoning as in the previous commit; see there. The bold span-node was clobbering the strikethrough attribute when that is set by an ancestor strikethrough node. (This is bolderWghtTextStyle's only caller, so it's simple to change its interface this way.)
1 parent 152aa5e commit c0d82e1

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

lib/widgets/text.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,11 @@ double bolderWght(double baseWght, {double by = 300}) {
288288
return clampDouble(baseWght + by, kWghtMin, kWghtMax);
289289
}
290290

291-
/// A [TextStyle] whose [FontVariation] "wght" and [TextStyle.fontWeight]
292-
/// have been raised using [bolderWght].
291+
/// A [TextStyle] with [FontVariation] "wght" and [TextStyle.fontWeight]
292+
/// that have been raised from the input using [bolderWght].
293+
///
294+
/// Non-weight attributes in [style] are ignored
295+
/// and will not appear in the result.
293296
///
294297
/// [style] must have already been processed with [weightVariableTextStyle],
295298
/// and [by] must be positive.
@@ -311,12 +314,9 @@ TextStyle bolderWghtTextStyle(TextStyle style, {double by = 300}) {
311314

312315
final newWght = bolderWght(wghtFromTextStyle(style)!, by: by);
313316

314-
TextStyle result = style.copyWith(
315-
fontVariations: style.fontVariations!.map((v) => v.axis == 'wght'
316-
? FontVariation('wght', newWght)
317-
: v).toList(),
318-
fontWeight: clampVariableFontWeight(newWght),
319-
);
317+
TextStyle result = TextStyle(
318+
fontVariations: [FontVariation('wght', newWght)],
319+
fontWeight: clampVariableFontWeight(newWght));
320320

321321
assert(() {
322322
result = result.copyWith(debugLabel: 'bolderWghtTextStyle(by: $by)');

test/widgets/content_test.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,14 @@ void main() {
707707
'<tbody>\n<tr>\n<td>text</td>\n</tr>\n</tbody>\n'
708708
'</table>'),
709709
styleFinder: findWordBold);
710+
711+
testWidgets('has strike-through line in strike-through', (tester) async {
712+
// Regression test for: https://github.com/zulip/zulip-flutter/issues/1817
713+
await prepareContent(tester,
714+
plainContent('<p><del><strong>bold</strong></del></p>'));
715+
final style = mergedStyleOf(tester, 'bold');
716+
check(style!.decoration).equals(TextDecoration.lineThrough);
717+
});
710718
});
711719

712720
testContentSmoke(ContentExample.deleted);

0 commit comments

Comments
 (0)