-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create accessible combobox #64
Comments
@jessegreenberg , @zepumph , @mbarlow12 I have coded up an HTML Please have a look in the html-sketches folder: |
I am going to put the design notes here in the issue and remove them from the example html. |
Example 1: HTML Design Pattern (working example) <label for="solute-options">Solute:</label>
<select id="solute-options" name="select">
<option value="1">Drink mix</option>
<option value="2">Colbalt (II) nitrate</option>
<option value="3">Colbalt Chloride</option>
<option value="4">Potassium dichromate</option>
<option value="5">Gold (III) chloride</option>
<option value="6">Potassium chromate</option>
<option value="7">Nickel (II) chloride</option>
<option value="8">Copper sulfate</option>
<option value="9">Potassium permanganate</option>
<option value="10">Potassium dichromate</option>
</select> Example 2: ARIA 1.0 Design Pattern (non-working example) In ARIA 1.1, the In the ARIA 1.0 design pattern example below, there are three attributes on the focusable HTML input element that has the These are:
I think in our case the widget is read-only, as it is not editable, but placing the HTML5 <input id="solute-comboxbox" tabindex="0" aria-label="Solute" type="text"
role="combobox" aria-expanded="false" aria-autocomplete="list"
aria-controls="owned-solute-listbox" aria-activedescendent="" readonly>
<ul role="listbox" id="owned-solute-listbox">
<li role="option" id="solute-option-01">Drink mix</li>
<li role="option" id="solute-option-02">Colbalt (II) nitrate</li>
<li role="option" id="solute-option-03">Colbalt Chloride</li>
<li role="option" id="solute-option-04">Potassium dichromate</li>
<li role="option" id="solute-option-05">Gold (III) chloride</li>
<li role="option" id="solute-option-06">Potassium chromate</li>
<li role="option" id="solute-option-07">Nickel (II) chloride</li>
<li role="option" id="solute-option-08">Copper sulfate</li>
<li role="option" id="solute-option-09">Potassium permanganate</li>
<li role="option" id="solute-option-10">Potassium dichromate</li>
</ul> |
Thanks for working on this @terracoda, looks great and nice mockups! I think we ran into trouble with the If it can't be hidden, we might be stuck with an ARIA pattern. |
The Whatsock example is working really nicely, I agree it is very complicated. |
For me the Whatsock example does not read out the individual options in VO and Safari. I only hear the selected language. |
Good to know @terracoda, thanks |
@jessegreenberg can you explain what you mean by "hide the options in the PDOM".
@jessegreenberg, are you concerned about number 2? or something else? Number 2 seems natural to me, but might complicate implementation. We might be able to restrict access to the options until the pop-up is actually open. I'd have to play with some things (hidden, aria-hidden, aria-expanded, css, etc). The size attribute doesn't seem to have any effect when set to 1. I'll wait for @zepumph to comment with details because right now |
The problem is that the HTML select box needs to be invisible for sighted users. The last time we tried to use Click in the grey box under 'Show' and press enter, and you will still see the box of options even though the select box is hidden. We couldn't figure out a way to hide this box with CSS, but there could certainly be a way we didn't think of. If we could use |
@jessegreenberg, I don't understand how jsfiddle is supposed to work, but does <div style="text-indent: -1000em;">
<label for="solute-options">Solute:</label>
<select id="solute-options" name="solute-options">
<option value="1">Drink mix</option>
<option value="2">Colbalt (II) nitrate</option>
<option value="3">Colbalt Chloride</option>
<option value="4">Potassium dichromate</option>
<option value="5">Gold (III) chloride</option>
<option value="6">Potassium chromate</option>
<option value="7">Nickel (II) chloride</option>
<option value="8">Copper sulfate</option>
<option value="9">Potassium permanganate</option>
<option value="10">Potassium dichromate</option>
</select>
</div> I think we may need to look seriously at how we are hiding the PDOM. Ideally, the entire thing is hidden in the same way. |
@jessegreenberg I see what you mean now. The grey box seems to return visually, eventhough everything is moved off screen. This needs some investigation. |
@terracoda I tried |
@jessegreenberg, yes, same with Safari. The position of the box is very persistent. |
@jessegreenberg, it finally disappeared with an option focus style applied. I'm not sure how robust this is, but I do not see the list of options or anything else in Safari. In the head... <style>
.hide-me {
text-indent: -1000em;
}
option:focus{
display: block;
text-indent: -1000em;
}
</style> And in the body... <div class="hide-me">
<label for="solute-options">Solute:</label>
<select id="solute-options" name="solute-options" size="1">
<option value="1">Drink mix</option>
<option value="2">Colbalt (II) nitrate</option>
<option value="3">Colbalt Chloride</option>
<option value="4">Potassium dichromate</option>
<option value="5">Gold (III) chloride</option>
<option value="6">Potassium chromate</option>
<option value="7">Nickel (II) chloride</option>
<option value="8">Copper sulfate</option>
<option value="9">Potassium permanganate</option>
<option value="10">Potassium dichromate</option>
</select>
</div> |
A negative left margin also seems to work. |
For example: <style>
.hide-me {
margin-left: -1000em;
}
option:focus{
display: block;
margin-left: -1000em;
}
</style> |
Awesome, thanks @terracoda! Unfortunately I tried the above in a JSFidddle and it didn't work for us in Safari, the box of options kept appearing. Would you mind sending a JSFiddle with it working in case we didn't use the right CSS? Or we could do a voice chat and share screens some time. |
@jessegreenberg, did you try the actual HTML file on github? |
I just tried https://github.com/phetsims/a11y-research/blob/master/html-sketches/combobox/combobox-examples.html, I can see the box in Safari 10.0.1 when I open it with spacebar. EDIT: it is hidden correctly in Chrome. |
Oh, I seemed to have been incorrect. I get the pop-up in Safari 11.01, too. |
Would this "detaching" method work in our situation? |
@terracoda I think that solution with |
@mbarlow12 looked into this example: It uses identical structure to HTML in #64 (comment), but with different elements, and different roles. If it sounds OK with supported AT we should use that. EDIT: I also notice that it uses aria-labelledby to indicate selected menu option. |
The above link dynamically adds the actual selector list content when the user interacts with the combobox. The structure of that content is: <span role="combobox" class="cbox" tabindex="0" aria-haspopup="listbox" aria-controls="controlID" aria-expanded="false" aria-autocomplete="list">
<span><!-- selected option here --></span>
</span>
<div> <!-- main list container, this is not in the dom until the user opens the list -->
<div></div>
<div><!-- actual list -->
<ul role="listbox" id="controlID">
<li role="option" tabindex="-1" id="someid" data-value="The option text" ></li>
<!-- ... -->
<!-- ... -->
</ul>
</div>
<a href="#"><!-- visually hidden link to close the selector box on keyboard nav --></a>
<div></div><!-- don't know what this does -->
</div> <!-- END: main list container -->
<select></select> <!-- the actual, persistent options --> |
That example sounds pretty good to me in FF + NVDA. We should discuss a few things with the team.
|
Great work @jessegreenberg and @mbarlow12, and thanks for looking at the whatsock example more deeply. I used it in my examples, too, but only really understand the HTML end of things. In the article posted in #64 (comment), Garaventa discusses the current limitations of the changed combobox role, so we need to make sure it is meeting our needs in our supported platforms. In #64 (comment)
I just want to repeat that type-ahead functionality is recommended in ARIA Practices, but not required. I will test the latest examples with VO in the morning. |
@jessegreenberg and @mbarlow12, regarding (#64 (comment)) I would gently caution against saying something has "identical structure" when in fact it contains "different elements, and different roles." These differences are key and exactly what we are trying to figure out. That said, thanks for re-posting Garaventa's code. It has We could try popping up a list with the role "listbox". That likely provides better interaction semantics than And @mbarlow12 points out in #64 (comment) that in the Garaventa example "the actual selector list content" is added dynamically. I think this is what we are trying to achieve. I tested Garaventa's combobox with keyboard alone and with VO and the keyboard (I tested it in my early investigation and again just now.) The example works fine with the keyboard alone, but works inconsistently with VO turned on. The main issue being that I never hear the list of possible option items in the popped up list and I am never notified of my successful new selection. Other issues are that activating the popped up list some times stops working, and sometimes I can't move through the options with the arrow keys, but these issues might be me and VO. |
@jessegreenberg and @mbarlow12, I tested the Molarity pop-up menu in #64 (comment) It sounds pretty good, except as we discussed last week the items are read out as menu items rather than options or list items. @jessegreenberg, I am wondering if we can combine the approach you are taking and use the semantics either from ARIA or HTML or a combination that provide list semantics. For example, something like this: The <div tabindex="-1" id="container-4-59-414-303-307">
<button id="4-59-414-303-307" tabindex="0" aria-haspopup="listbox" aria-labelledby="description-4-59-414-303-307">Solute</button>
<p tabindex="-1" id="description-4-59-414-303-307">Drink mix, selected</p>
</div>
<ul tabindex="-1" id="4-59-414-274-304" role="listbox" hidden="">
<li tabindex="-1" id="4-59-414-274-304-313" role="option">Drink mix</li>
<li tabindex="-1" id="4-59-414-274-304-315" role="option">Cobalt (II) nitrate</li>
<li tabindex="-1" id="4-59-414-274-304-317" role="none">
...
</ul> OR, something like this: <div tabindex="-1" id="container-4-59-414-303-307">
<button id="4-59-414-303-307" tabindex="0" aria-haspopup="listbox" aria-labelledby="description-4-59-414-303-307">Solute</button>
<p tabindex="-1" id="description-4-59-414-303-307">Drink mix, selected</p>
</div>
<ul tabindex="-1" id="4-59-414-274-304" role="listbox" hidden="">
<li tabindex="-1" id="4-59-414-274-304-313"><option value="1">Drink mix</option></li>
<li tabindex="-1" id="4-59-414-274-304-315" ><option value="2">Cobalt (II) nitrate</option></li>
...
</ul> |
@terracoda said that the combobox role is not well supported by AT. |
@terracoda said that a listbox has better semantics for this UI element. We will add the roles and change the elements so that it looks like the the first example listed in #64 (comment). |
We will try the first example @terracoda posted in the above comment and report back on how it sounds. That will help determine whether use roles that create a listbox or popup menu. |
https://www.w3.org/TR/wai-aria-1.1/#menu "A type of widget that offers a list of choices to the user. A menu is often a list of common actions or functions that the user can invoke. The menu role is appropriate when a list of menu items is presented in a manner similar to a menu on a desktop application. To be keyboard accessible, authors SHOULD manage focus of descendants for all instances of this role, as described in Managing Focus. Elements with the role menu have an implicit aria-orientation value of vertical." Given the above description, then menu role could be viable assuming it provides a good experience for ATs. |
@mbarlow12 and @jessegreenberg worked on this today. We implemented the markup in the first example of #64 (comment). @terracoda correctly predicted that aria-labelledby would override the accessible name for the pop up button, so we kept aria-describedby. Here is a link, @terracoda what do you think? It sounds good with NVDA + FF, and @mbarlow12 also tested in Safari with VO. One benefit of this version is that items are correctly counted, so when the listbox is open, the AT might say |
I like the counting semantics. Nice job @jessegreenberg and @mbarlow12! I'll review the keyboard interactions later. Awesome combination of ideas! |
@jessegreenberg, @mbarlow12, @jhung, @emily-phet I found an implemented The above example also uses two things to dynamically label the pop-up button:
This double-labeling technique, solves the short comings of I suggest we dynamically change the label of the button to the selected solute, and use Here's a snippet of suggested HTML. I used word-based id's to explicitly demo the approach. You could use PhET's number id's, of course in your code. <div tabindex="-1" id="container-4-59-414-303-307">
<span id="button-static-label-01">Choose a Solute:</span>
<button id="button-dynamic-label-02" tabindex="0" aria-haspopup="listbox" aria-labelledby="button-static-label-01 button-dynamic-label-02">Drink Mix</button>
</div>
<ul tabindex="-1" id="4-59-414-274-304" role="listbox" hidden="">
<li tabindex="-1" id="4-59-414-274-304-313" role="option">Drink mix</li>
... I also re-read the specification for listbox and the recommendations in ARIA Practices to review guidance on not using auto-selection, and to review any recommended keyboard shortcuts. It is totally fine to not use auto-selection. Our design case is better without auto-selection. And regarding keyboard patterns and shortcuts, here's how I think our
Optional, but useful for Molarity as there are more than 5 items
Usually used on a multi-select
Roles, States and Properties for out
Things to consider for the issue about Visual Design (Moved to #73)
|
@jessegreenberg and @mbarlow12, I am un-assigning myself from this issue. A few more additions to our combobox and I think we will have a really nice one. Hopefully, AT and browsers will agree! Let me know if you have any questions. |
This will be added into the accessibility API update, related to |
Adding another resource which I just came across in case we need to refer to it later |
@terracoda to update html mock-up to use two labels with aria-labelledby. |
@jessegreenberg , @mbarlow12 , @zepumph, @emily-phet I hear both labels when entering the listbox with the cursor keys, but not when placing focus with the Tab key. That's possibly how it is supposed to work. I will review the one more time before committing. I think we have a relatively good solution. |
I was reviewing the incorrect example. @jessegreenberg and I figured it out. @jessegreenberg or @mbarlow12 would you like to add the JS that makes the example actually collapse and open? |
@jessegreenberg, @mbarlow12, and @zepumph. I updated the original file to include a 5th example, and then I decided to create a new file combobox.html that is final clean version. It sounds good. I tried changing the Could one of you add the necessary JS to pop-up the listbox and to manage the necessary aria-attributes? Or would you rather just implement directly in Molarity? @jessegreenberg and I thought it might be nice top have a working HTML example. |
I unassigned myself. @jessegreenberg and @mbarlow12, please re-assign if you have any questions. |
When we are ready to implement the combobox, we should re-compaare our code with the approach described here |
@zepumph has implemented the first accessible combobox in phetsims/sun#314, so I am closing this issue. |
Gathering resources for combobox:
The text was updated successfully, but these errors were encountered: