-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Add support for setting the heading level for web semantics (#97894) #125771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for setting the heading level for web semantics (#97894) #125771
Conversation
|
The build is failing because the engine part must be approved. I need to integrate both changes together (framework and engine part) for integration tests to pass. Please, someone can tell me how I should deal with this?. Maybe @yjbanov can shed some light? Thank you! |
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also have logic to automatically apply these when people using builtin text style in theme
|
|
||
| /// The hierarchy level of the widget as a header. | ||
| /// | ||
| /// This should only be set when [SemanticsFlag.isHeader] is set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this true? the isHeader may be closer to banner in aria.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, a widget with isHeader attribute gets a "role=heading" aria attribute, not a "banner" role. For that reason I consider this change is needed, a "heading" role needs an "aria-level". Webs without this do not pass accessibility static analysis checks and we really need this for a specific project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isHeader attribute gets a "role=heading
is this already the case in web? I remember when I last revisited this, only the Appbar has the isHeader = true. and Appbar is closer to banner in html https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/banner_role
The heading, ie h1, h2, h3 seams to be a different thing in html
cc @yjbanov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be answered yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @chunhtai, sorry for replying so late. Yes, I don't know what's the purpose of having that parameter enabled for the AppBar, but I can confirm applying the "header" attribute has the effect I mention, I tested it many times, also you can see evidence in this code (part of the engine)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think flutter web's usage of role=heading is incorrect. It was my mistake, as I was misunderstood what isHeader meant. "banner" seems closer to what it means in Flutter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case and we change isHeader to "banner", there won't be a way to add headings and levels in flutter web. Having a heading structure is an important feature in order to have decent web accessibility. Should we have another attribute for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isHeader is named after the similar widget in mobile platforms.
Android called it heading
It seems to me the mobile header or heading is the equivalent banner in web.
Should we have another attribute for this?
Isn't the heading level enough for this? we need to make sure we document that the heading level has nothing to do with the isHeader property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not addressed yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems not addressed yet?
Sorry, not yet, but I will address it. If I understood correctly the idea is to separate both attributes, changing "heading" property to be used to establish a "banner" role in web, and dedicate the headingLevel attribute to add the element as a header role with its corresponding level.
| _setFlag(SemanticsFlag.isHeader, value); | ||
| } | ||
|
|
||
| /// Indicates the owning [RenderObject]'s hierarchy level. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc is a bit confusing. what is a hierarchy level?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add more detail to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I tried to add more details. Please let me know if still should add more information. Thank you.
| int? _currentValueLength; | ||
|
|
||
| bool _canPerformAction(SemanticsAction action) => _actions.containsKey(action); | ||
| /// The level of the widget (when it's defined as a header) within |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First paragraph should be a brief sentence also this can use more explanation. can this parameter make sense out side of dom or markdown? If not, we should add document in terminologies in dom or markdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I tried to add more specific explanation here, please let me know if I should add/change something else. Thank you!
| /// [Directionality] or an explicit [textDirection] should be provided. | ||
| final String? tooltip; | ||
|
|
||
| /// The level of the widget (when it's defined as a header) within |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also changed this, hope it's better now. Thank you.
Sorry @chunhtai, I didn't get this. You mean the heading level should automatically be applied with a default value? |
The Text theme has h1~h6 style (which was replace by displayLarge, displayMedium.. etc). I was wondering where we may have a way to auto apply the semantics headinglevel if these style are in use. One idea would be make TextStyle carry heading level |
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @victorgalo , are you still planning on coming back to this pr?
|
|
||
| /// The hierarchy level of the widget as a header. | ||
| /// | ||
| /// This should only be set when [SemanticsFlag.isHeader] is set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be answered yet
This can be a separate pr though |
Hi @chunhtai. Yes, sorry for taking so long to reply. I would really appreciate my changes to be included. |
Oh I understand, sounds like a nice idea, but not sure how to handle that, because as you said, the h1-h6 were replaced and I don't see any way to relate the levels. Maybe it made more sense when those theme styles existed. If you are ok, we can deal with that in another PR. |
|
Hi @victorgalo are you still planning on working on this pr? The discussion seems to not be resolved yet #125771 (comment) |
Yes I will, sorry for the delay. |
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
# Conflicts: # packages/flutter/test/semantics/semantics_update_test.dart
|
auto label is removed for flutter/flutter/125771, due to This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.
|
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Manual roll Flutter from 4608a89 to fc19ecf (38 revisions) Manual roll requested by [email protected] flutter/flutter@4608a89...fc19ecf 2024-06-07 [email protected] Fix `SegmentedButton` clipping when drawing segments (flutter/flutter#149739) 2024-06-07 [email protected] Shift consistently passing tests on mokey to prod (flutter/flutter#149902) 2024-06-07 [email protected] Prepare images for tests individually to enable clean up of cache. (flutter/flutter#149693) 2024-06-07 [email protected] Roll Packages from 586faa6 to 8a2c4e4 (8 revisions) (flutter/flutter#149900) 2024-06-07 [email protected] Roll Flutter Engine from 98e9393bf2e9 to 1cdbebee1901 (4 revisions) (flutter/flutter#149899) 2024-06-07 [email protected] Roll Flutter Engine from 087feab9922b to 98e9393bf2e9 (1 revision) (flutter/flutter#149875) 2024-06-07 [email protected] Refactor `widget_inspector_test.dart` (flutter/flutter#149850) 2024-06-07 [email protected] Add test for dropdown_menu.1.dart (flutter/flutter#149547) 2024-06-07 [email protected] Add test for standard_fab_location.0.dart (flutter/flutter#149225) 2024-06-07 [email protected] [native_assets] Fix framework name deduplication (flutter/flutter#149761) 2024-06-07 [email protected] Roll Flutter Engine from 47b15dfba1da to 087feab9922b (1 revision) (flutter/flutter#149871) 2024-06-07 [email protected] Roll Flutter Engine from 5d5e0ee9102c to 47b15dfba1da (2 revisions) (flutter/flutter#149870) 2024-06-07 [email protected] Roll Flutter Engine from fea8e51b0280 to 5d5e0ee9102c (2 revisions) (flutter/flutter#149867) 2024-06-07 [email protected] Roll Flutter Engine from 5a0a49939c64 to fea8e51b0280 (2 revisions) (flutter/flutter#149865) 2024-06-07 [email protected] Roll pub packages (flutter/flutter#149864) 2024-06-06 [email protected] Roll Flutter Engine from bf1a4877da0b to 5a0a49939c64 (1 revision) (flutter/flutter#149861) 2024-06-06 [email protected] Remove some vestigial /*!*/ comments (flutter/flutter#149361) 2024-06-06 [email protected] Attempt to fix some web test flakiness. (flutter/flutter#149828) 2024-06-06 [email protected] Remove abi key permanently from golden file testing (flutter/flutter#149858) 2024-06-06 [email protected] [CupertinoActionSheet] Add sliding tap gesture (flutter/flutter#149471) 2024-06-06 [email protected] Roll pub packages (flutter/flutter#149852) 2024-06-06 [email protected] SliverResizingHeader (flutter/flutter#143325) 2024-06-06 [email protected] Run tests on macOS 13 or 14 (flutter/flutter#149827) 2024-06-06 [email protected] Fix leaky test. (flutter/flutter#149823) 2024-06-06 [email protected] Roll Flutter Engine from 31804a222f97 to bf1a4877da0b (3 revisions) (flutter/flutter#149848) 2024-06-06 [email protected] Add support for setting the heading level for web semantics (#97894) (flutter/flutter#125771) 2024-06-06 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Introduce `ChipAnimationStyle` to override default chips animations durations (#149245)" (flutter/flutter#149847) 2024-06-06 [email protected] 3.22.2 release notes (flutter/flutter#149818) 2024-06-06 [email protected] Roll Flutter Engine from 25bcbb888939 to 31804a222f97 (3 revisions) (flutter/flutter#149837) 2024-06-06 [email protected] Introduce `ChipAnimationStyle` to override default chips animations durations (flutter/flutter#149245) 2024-06-06 [email protected] Roll Flutter Engine from f5a9690c6061 to 25bcbb888939 (1 revision) (flutter/flutter#149835) 2024-06-06 [email protected] Fix leaky test. (flutter/flutter#149822) 2024-06-06 [email protected] Unpin archive package from tool, update to version without security advisories (flutter/flutter#149430) 2024-06-06 [email protected] Roll pub packages (flutter/flutter#149630) 2024-06-06 [email protected] Roll Flutter Engine from d9684a37af06 to f5a9690c6061 (7 revisions) (flutter/flutter#149832) 2024-06-06 [email protected] Roll Packages from 11e192a to 586faa6 (13 revisions) (flutter/flutter#149820) 2024-06-06 [email protected] Fix some links in the "Handling breaking change" section (flutter/flutter#149821) 2024-06-06 [email protected] Roll Flutter Engine from 92d0cd9370f7 to d9684a37af06 (1 revision) (flutter/flutter#149793) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. ...
|
I don't think the headingLevel is working? Try this with MacOS Voice Over: Try to select heading with voice over, it says that the Flutter Demo Home Page is the last heading. You can't navigate to the second heading with keyboard arrows either. |
|
Hi @k0psutin it hasn't hook up to desktop embedding i believe. can you open a new issue for this? |

This change adds a new property in Semantics widget that would take an integer corresponding to the heading levels defined by the ARIA heading role. This is necessary in order to get proper accessibility and usability in a website for users who rely on screen readers and other assistive technologies.
Issue fixed by this PR:
fixes #97894
Engine part:
flutter/engine#41435
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on [Discord].