flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[BUG] Wrong semantics ordering

Open JankoLancer opened this issue 3 months ago • 1 comments

Describe the bug: Html widget does not seem to compose the semantics label in the actual order. Here is the test reproducing issue:

testWidgets('semantics label not in order in html', (tester) async {
  await tester.pumpWidget(
    Directionality(
      textDirection: TextDirection.ltr,
      child: Html(data: """
          <p>before</p>
          foo
          <p>after</p>
        """),
    ),
  );
  expect(tester.getSemantics(find.byType(Text).first),
      matchesSemantics(label: 'before \nfoo\n after'));
});

Error message:


Expected: has semantics with label: before
          foo
           after 
  Actual: SemanticsNode:<SemanticsNode#1(Rect.fromLTRB(0.0, 0.0, 800.0, 115.0) scaled by 3.0x,
label: "before\nafter\nfoo", textDirection: ltr)>
   Which: label was: before
          after
          foo

HTML to reproduce the issue: <p>before</p> foo <p>after</p>

Html widget configuration: No configuration needed

Expected behavior: The semantics order should be before \nfoo\n after, like they are visually presented.

Screenshots:

Device details and Flutter/Dart/flutter_html versions: Dart: 3.2.6 Flutter: 3.35.4

Stacktrace/Logcat

Additional info:

A picture of a cute animal (not mandatory but encouraged)

Image

JankoLancer avatar Oct 06 '25 09:10 JankoLancer

It seems there is an issue with nested Text.rich widgets. I opened Flutter bug issue https://github.com/flutter/flutter/issues/176570

JankoLancer avatar Oct 06 '25 10:10 JankoLancer