-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Added consistent aria levels to any role='heading' #5782
Conversation
@ekawatani @hoovercj @jspurlin @philipzloh @cschlechty I found all of the role="heading" in fabric and tried to come up with a solution based on your feedback. Tell me if the above guidance appears correct. |
Didn't mean to close the PR... The guidance is not correct in terms of an application or "widgets". aria-level can be relative/contextual, for example: menu, treeview, or tree. The current guidance seems to be thinking to literally about the h1 through h6 html element for traditional web pages |
can/should we add aria-level to our basecomponent? So it could be passed in to all components (and obviously only used by the ones that need it). |
nah....that'd infer that aria-level would be placed onto the root...no good |
also, aria-level can be contextual so basing it off of a parent might not make sense |
@@ -1119,7 +1121,7 @@ export class ComboBox extends BaseComponent<IComboBoxProps, IComboBoxState> { | |||
const { onRenderOption = this._onRenderOptionContent } = this.props; | |||
|
|||
return ( | |||
<div key={item.key} className={this._classNames.header} role="heading"> | |||
<div key={item.key} className={this._classNames.header} aria-level={this.props.label ? 3 : 2} role="heading"> |
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.props.label ? 3 : 2 [](start = 74, length = 24)
Please do leave a comment as to why label informs 3/2 here. To someone without the context that you have, this can look very arbitrary.
@@ -344,6 +344,8 @@ export class ComboBox extends BaseComponent<IComboBoxProps, IComboBoxState> { | |||
required={required} | |||
htmlFor={id + '-input'} | |||
className={this._classNames.label} | |||
aria-level={2} | |||
role="heading" |
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.
I doubt we'd want headings built in to combo boxes or other simple controls. Headings are mean to provide hierarchical page structure.
So what are the places that actually need role="heading" and therefore aria-level? Is it just panel and dialog right now? And if so, can we simply go with a default value of 2, or do we need to leave that open for customization? |
Having those as level 2 seems reasonable as long as we don't put them as descendants of things level 2 or lower. |
…nd panel with aria-level 2
If aria-level is contextual, then the default value for these heading elements in popup boxes like ContexualMenu, and Panel should be 1 as this comment mentions. If it's set to 2, user will look for heading level 1 that doesn't exist. We should open it up for customizing the aria-level if the component provides a way to custom-render parts of the component. For example, the |
No. There should be only one heading of level 1 on a page. The levels are contextual in that it should make sense hierarchically, under h2s, you have h3s, etc. Where the controls are in the DOM structure will partially determine the level, so it needs some level of customization. |
I'm a bit confused. For dialogs and such that appear overlaid over the content, with their root element perhaps being outside the main h1 of the page (last child of the body tag, for example, with the h1 being a few divs deep in the body), what is the expected heading level of the dialog heading? Hierarchically in the dom it would be 1, but semantically on the page, perhaps 2? What does the spec suggest here? And then consider a form on a page. Page header is level 1, form header is level 2, then if you start rendering menu items in the form, would their headings not be level 3+? But what if, again, these menu items actually get rendered elsewhere in the dom but are "owned" by the form? In the dom they may not have a parent with a heading level. Does the spec give guidance here? |
As in my other comment, I don't really understand or see the correctness in having a The point is not that there can only be one thing that is |
It's technically incorrect to have an aria-level > 1 without all of the previous levels accounted for in the same section (in your example, a dialog) |
You probably just want that to be the label for a group of options. Using
options, that'd be an optgroup. With custom markup, it's probably just a
vanilla role="group". see https://www.w3.org/WAI/tutorials/forms/grouping/
…On Fri, Aug 3, 2018 at 1:37 PM, jspurlin ***@***.***> wrote:
@philipzloh <https://github.com/philipzloh> these are heading in a menu,
what else would you call them?
[image: image]
<https://user-images.githubusercontent.com/7033561/43664607-5720ac4c-9722-11e8-85e6-325cb6592448.png>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#5782 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ATa0j8TzPRNKzevGTHw4FCp_1GFimbsWks5uNLSigaJpZM4Vsy6e>
.
|
@jspurlin If I were super pedantic, that's incorrect / non-standard usage of menu? I understand that it shows up in our menus, but in a standard menu it should have been represented as:
In our case, we should probably represent this in pseudo-DOM as
|
@philipzloh and @cschlechty yep, that's an alternative approach to fix this and would actually result in a better readout |
Is there a final approach we all agree on? Is this PR good as is, or do we need to support custom aria-level values for these two surfaces. And if there is further work to be done for the ComboBox and contextualMenu, can we put that into a separate issue? |
Let me toss out resolution for this PR.
|
We should only remove the role=heading if we are also doing the aria-labelledby group (with aria-hidden on the actual heading element) approach. Otherwise if a use is consuming the menu with virtual focus it will announce those elements a " group" which is worse than it currently is. |
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 eventually add menu sections per W3C, but this is a solid improvement.
Pull request checklist
$ npm run change
Description of changes
As per conversation, level 1 is reserved for page level headings (which our components will rarely be). So I've set everything at a default of 2, unless they are items inside of a component that already has a level 2, in which case it changes to level 3.
This switching behavior was already in contextual menu, so I made combobox consistent.
Focus areas to test
(optional)
Microsoft Reviewers: Open in CodeFlow