Skip to content

[BUG] Wrong semantics ordering #1495

@JankoLancer

Description

@JankoLancer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions