Repository navigation
a11y(a2ui_flutter): mark Text and Markdown headings as headings in the semantics tree - #3788
karolkulesza wants to merge 35 commits into
Conversation
…e semantics tree The h1-h5 variants and a one-line Markdown heading in a body Text are wrapped in Semantics(container: true, header: true, headingLevel: n), so screen readers announce them as headings and can navigate by them, like the <h1>-<h5> elements on the web and the SwiftUI change in a2ui-project#3761. The container keeps the heading flag from merging into the texts beside it in a Card or a labelled component. Button now merges the semantics of its child, so a heading (or labelled) child still gives the button its name.
…semantics # Conflicts: # dart/a2ui_flutter/CHANGELOG.md
There was a problem hiding this comment.
Code Review
This pull request adds heading semantics to the Text component for h1-h5 variants and Markdown heading lines, allowing screen readers to navigate them. It also attempts to merge semantics in the Button component. The reviewer feedback points out that merging semantics on Button causes it to incorrectly inherit heading properties, which is an accessibility anti-pattern. The reviewer suggests introducing an ExcludeHeadingSemantics inherited widget to disable heading semantics for children of a Button while still allowing the button to inherit the text label, and provides corresponding updates for the tests and changelog.
…e button a heading
…semantics # Conflicts: # dart/a2ui_flutter/CHANGELOG.md
|
Hi @karolkulesza, thank you for raising this PR and addressing the review comments. Could you please rebase or merge the latest main branch to resolve the merge conflict in dart/a2ui_flutter/CHANGELOG.md? |
…semantics # Conflicts: # dart/a2ui_flutter/CHANGELOG.md
|
Thanks @Varun-S10. I merged the latest main in 08f54db. The conflict was only in |
|
Hi @karolkulesza, thank you for merging the latest main branch and resolving the conflict. We have verified the updated PR and it resolves the issue cleanly. I will escalate this to the team for review. Thank you for your patience and understanding. |
|
From triage bot, analysis: For humansTL;DR Summary: Targeted issues: Suggestion: The PR meets the review criteria:
The author addressed the Gemini review: a heading Text inside a Button is no longer marked as a heading (reply). GitHub reports no merge conflict.
To adjust the analysis and apply its suggestion, run in your a2ui checkout: tools/internal/triage/triage_ui.sh https://github.com/a2ui-project/a2ui/pull/3788For softwareThis analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision. 🤖 Agent-generated |
|
Thanks for the change and the tests. Assigning this PR to |
Description
Flutter counterpart of #3761. The Flutter
Textcomponent styles theh1–h5variants, and a body Text that is one Markdown heading line (## Title), with heading fonts, but the semantics tree doesn't mark them as headings. TalkBack and VoiceOver read them as plain text, and heading navigation finds nothing on an A2UI surface. The web renderer emits<h1>–<h5>for the same variants, and SwiftUI now sets the heading trait and level.Changes:
buildText: theh1–h5variants and a one-line Markdown heading are wrapped inSemantics(container: true, header: true, headingLevel: n). A Markdown heading keeps its real level, 1 to 6, though######still takes theh5style. Body, caption, multi-line and quote text are unchanged.container: trueis needed: without it the heading flag merges into the enclosing node, so in aCard(or a component with anaccessibility.label) the body text next to the heading was announced as part of the heading.buildButton: the button is wrapped inMergeSemantics. A Button'schildcan be any component, and Material buttons only take their name from descendants that aren't semantics containers. Without the merge, a Button whose child is anh2Text would have an empty name. With it, the button reads "Go", as a button and a level-2 heading. This also gives a name to a Button whose child has its ownaccessibility.label, which had the same empty-name problem on main.#,###and######Markdown lines, and no heading for caption, body, plain,#######, multi-line and quote text (leaf_components_test.dart). A heading next to body text in aCardand in a labelled Column keeps the flag to itself. A Button with anh2child is named "Go" (button_test.dart).Text built by an app's own
A2uiMarkdownbuilder is not touched: the app's Markdown widget owns the semantics of its headings.Testing:
flutter testindart/a2ui_flutter: 407 passed (after merging main). The new Text tests fail without thetext.dartchange, the Card/labelled-Column test fails withoutcontainer: true, and the Button test fails without thebutton.dartchange.dart analyze: no issues.dart format: clean.Part of #2738.
Pre-launch Checklist
One time:
For this PR:
If you need help, consider asking for advice on the discussion board.