Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 117 additions & 1 deletion html-aam/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,83 @@ <h4 id="el-button">`button`</h4>
</tr>
</tbody>
</table>

<h4 id="el-button-select-child">`button` as a child of a `select` element</h4>
<table aria-labelledby="el-button-select-child">
<tbody>
<tr>
<th>HTML Specification</th>
<td>
<a data-cite="HTML">`button`</a>
</td>
</tr>
<tr>
<th>[[wai-aria-1.2]]</th>
<td>
<div class="general">Not mapped. <a href="#el-button-select-child-comments">See comments</a>.</div>
<!-- a button that is a child of a select is not a typical "button" element.
it does not serve as a submit, reset, or generic 'button' type. Rather,
its purpose is directly tied to the rendering of a customized select
serving as the visible indicator/styleable node to serve as the
invoking element for the select's listbox popup.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to mention that the UA stylesheet applies interactivity: inert to this button, to ensure that this comment is true (modulo developer shenanigans)?

-->
</td>
</tr>
<tr>
<th><a data-cite="core-aam-1.2/#roleMappingComputedRole">Computed Role</a></th>
<td class="role-computed">
<div class="general">Not mapped. <a href="#el-button-select-child-comments">See comments</a>.</div>
</td>
</tr>
<tr>
<th>
<a href="https://msdn.microsoft.com/en-us/library/dd373608%28v=VS.85%29.aspx">MSAA</a> + <a href="http://accessibility.linuxfoundation.org/a11yspecs/ia2/docs/html/">IAccessible2</a>
</th>
<td>
<div class="general"><a href="#el-button-select-child-comments">See comments</a></div>
</td>
</tr>
<tr>
<th><a href="https://msdn.microsoft.com/en-us/library/ms726297%28v=VS.85%29.aspx">UIA</a></th>
<td>
<div class="general"><a href="#el-button-select-child-comments">See comments</a></div>
</td>
</tr>
<tr>
<th><a href="https://gnome.pages.gitlab.gnome.org/atk/">ATK</a></th>
<td>
<div class="general"><a href="#el-button-select-child-comments">See comments</a></div>
</td>
</tr>
<tr>
<th><a href="https://developer.apple.com/reference/appkit/nsaccessibility">AX</a></th>
<td>
<div class="general"><a href="#el-button-select-child-comments">See comments</a></div>
</td>
</tr>
<!-- <th><a href="#accessible-name-and-description-computation">Naming Algorithm</a></th> -->
<tr>
<th id="el-button-select-child-comments">Comments</th>
<td>
<p>
User agents treat the child `button` element of a `select` element as inert.
The `select` and its child `button` part are meant to be considered a single item to users and in the user agent's accessibility tree.
</p>
<p>
The <a data-cite="accname-1.2/#mapping_additional_nd_te">text equivalent computation</a> of the subtree of the
`button` element participates in the accessible value calculation of the `select` element.
See the <a href="#el-select-combobox">`select`<span class="el-context"> (with NO `multiple` attribute and NO `size` attribute having value greater than `1`)</span></a> for more information.
</p>
<p>
User agents MAY warn developers that the use of global HTML or ARIA attributes, or attributes specific to the `button` element or ARIA's `button` role are not expected to be used on a `button` element in this context.
</p>
<p class=note>
As this `button` element is inert, any use of global HTML or ARIA attributes, or attributes specific to the `button` element or ARIA's `button` role are not exposed to the user agent's accessibility API.
</p>
</td>
</tr>
</tbody>
</table>
<h4 id="el-canvas">`canvas`</h4>
<table class="data" aria-labelledby="el-canvas">
<tbody>
Expand Down Expand Up @@ -6420,7 +6497,46 @@ <h4 id="el-select-combobox">`select`<span class="el-context"> (with NO `multiple
<!-- <th><a href="#accessible-name-and-description-computation">Naming Algorithm</a></th> -->
<tr>
<th>Comments</th>
<td></td>
<td>
<p>To calculate the accessible value of a `select` element:</p>
<ol>
<li>If `aria-valuetext` is specified on the `select` element, use the attribute's value, including the empty string.</li>
<li>Else if there is a `button` part, calculate the accessible value from a non-empty string <a data-cite="accname-1.2/#mapping_additional_nd_te">text equivalent computation</a> of the subtree of that element.</li>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything in the HTML spec that prevents the author from putting something other than the value in the button part? For example, what if the author puts a label in the button part? It would be very weird to expose a label as the value. Obviously, we can't stop authors from doing this, but I wonder if they should at least be warned against it, though that probably belongs in the HTML spec itself.

<li>If the `select` element does not have an `aria-valuetext` attribute and has not calculated a usable value from its button part, then the accessible value is calculated from the accessible name of the selected `option` element, even if the accessible name of the selected `option` is the empty string.</li>
</ol>
<!-- provide a link to the ARIA spec when the https://github.com/w3c/aria/pull/2417 PR lands -->

<p>
The calculated role of the customizable `select` element's popup picker is a `listbox`, by default.</p>
<p>
If authors include invalid elements (according to the the `select` element's content model) as descendants of the `select` element, and those invalid elements result in accessible objects being present as siblings in the accessibility tree to the valid descendent elements of the select, then user agents SHOULD expose the popup picker with the role of `dialog` in the modeless state.</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation requirements that depend on content model are unusual. Browsers typically don't include conformance checkers, so can't easily tell if the content model is being violated or not. What is the purpose here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for pointing this out @zcorpan

the rational here was talked about a lot in open ui, but the high level gist is that since the parsing for select was changed to allow for anything, the role of the popup needs to let users know whether they're interacting with a version that follows the content model (and thus can be exposed as a listbox) or has elements in it which are important to make AT users aware of / doesn't follow the content model, and thus was decided to be exposed as a dialog to help surface this to users.

with that said though, i talked with @mfreed7 about this and we were thinking that to mitigate this explicit reference to the content model, we this can be updated to more overtly call out what HTML elements / allowed implicit roles will allow for the default role=listbox, and how the inclusion of others would result in the popup needing to be role=dialog.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I understand why it's being proposed, this is the part of customisable select accessibility that worries me the most.

Mutations are a big concern here. What if the <select> started out entirely valid when it was first rendered, but then an author added more elements such that it became invalid? Or on the flip side, what if it were invalid and then became valid? Since we're effectively talking about UA repair for invalid authoring, it's not super important how we fail, but the failure mode needs to be clearly defined. This can't be undefined (unspecified) behaviour if we want interoperable implementations that don't later cause web compat pain.

Perhaps we could state that the role is determined based on the initial rendering of the <select>. If it starts out as valid and an author later makes it invalid, that's their loss. We'll only correct for authoring error to a point. I think this would be the most pragmatic solution and would be the least likely to cause implementation pain and performance problems.

If we do want to handle mutations from valid to invalid and vice versa, there are some difficult issues we need to address:

  1. Most accessibility APIs don't have role change events (or at least not role change events that clients heed). Should the role just mutate silently, risking confusing the client, or should the subtree be recreated whenever validity changes? Recreating subtrees is expensive all the way through the accessibility stack, particularly if there are a lot of nodes. Even mutating the role silently has performance costs; see below.
  2. Checking whether validity has changed is not trivial. Unless I'm missing something, we'd need to re-evaluate this every time a descendant is added to a select. At the very least, this probably means walking the ancestry for every insertion or removal, since caching a select ancestor on every node would waste a lot of memory. Anything that adds even the tiniest bit of work for all insertions into the tree, even if it's just an ancestor walk with a simple check, is a potential performance cliff. This possibly also means walking all the non-generic children of the select as well, though we could maybe get around this caching the validity state on the select. In general, any specified behaviour here needs to take performance concerns into account.

CC @eeejay for awareness and input, since he will likely be doing the Gecko implementation for this and has also done some recent work regarding role calculation. CC also @lucasradaelli from Chrome accessibility, since aleventhal is no longer working on that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that this is a pain point.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the hypothetical here that the select has a mix of invalid elements and option elements, the role would be a dialog. But I am unclear of how a platform API or AT would deal with option accessibles that are children of dialog and have no listbox ancestor.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My humble proposal:

  • If the select initially has a valid content model, and then an invalid child is added, it should remain a listbox with unspecced behavior, just like how a non-group/option child would affect an explicit aria listbox.
  • If the select initially has an invalid content model its role would be a dialog. All select children would get generic roles. The dialog role is immutable and won't change to a listbox if the invalid children are removed.


<p>
In the event invalid elements are present, but are not rendered, then no user agent role repair is necessary.</p>
<p>
In the event that invalid elements are present, but are empty, include only whitespace, or are only used as wrapping elements for the valid descendent element's of a select, then user agents SHOULD ignore these elements in the accessibility tree.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is even more concerning. It's probably feasible to do this for empty elements in the initially rendered subtree. It's slightly trickier (but probably still feasible) to do this when new empty elements are inserted into an otherwise valid select. But what if someone inserts an empty <article> into a <select> (so it's ignored), but later inserts a child that makes the <article> invalid? Now we're not just making decisions based on the type of the element. The decisions also have to take into account the contents of that element. That means we're doing even more walk on every insertion into the tree.

Also, does "include only whitespace" explicitly refer to direct children or is this suggesting that we need to evaluate the contents overall. For example, does <article><span> <span> </span></span></article> get ignored or not? What about <article>&nbsp</article>? I'm guessing this is only intended to cover cases like <article> </article>, but this probably needs to be clarified. Even just saying "includes only a single whitespace child" is probably sufficient clarification.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why empty invalid tags are an exception here. What is the use-case?

In my proposal above, I could see an empty invalid tag as a method of insuring the picker gets a role of dialog even if there is no initial content, eg:

<select>
  <button>
    <selectedcontent>Select a pet:</selectedcontent>
  </button>
  <article></article>
</select>

</p>

Comment thread
scottaohara marked this conversation as resolved.
Resolved
<div class=example>
<p>In the following example the declared `article` elements are invalid per the `select` element's content model. But as each `article` element is empty, contains only whitespace, or contains only valid `option` elements, the `article` element's role can be ignored in the user agent's accessibility tree:</p>

<pre><code>
&lt;select>
&lt;button>&lt;selectedcontent>&lt;/selectedcontent>&lt;/button>
&lt;article> &lt;/article> <!-- empty / containing only white space so can be ignored -->
&lt;article> <!-- only contains option elements, so article role can be ignored -->
&lt;option>item 1
&lt;option>item 2
&lt;/article>
&lt;article hidden> foo &lt;/article> <!-- article is in the hidden state, so is ignored -->
&lt;/select>
</code></pre>
</div>

<p class=note>Treating the picker as a `dialog` can help inform users that content beyond the expected elements of a `listbox` popup are present, as they can then inspect the content of the dialog with their assistive technology to discover such content.</p>

<p>See also <a href="#el-button-select-child">`button` element as a child of a `select` element.</p>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better readability, should we move (or duplicate) the link to the 'button as a child of a select element' section closer to the second bullet point in the accessible name computation? It might help readers understand, for example, why an aria-label set on the button doesn’t contribute to the accessible name computation.

</td>
</tr>
</tbody>
</table>
Expand Down