Let’s say I have a list of checkboxes inside a <fieldset>
. I want the user to be able to filter this list (given that this is pretty big), that is, you type something in this input, and only the checkboxes that match this input will be visible. What WAI-ARIA tags are required on this input and/or the checkboxes?
Or is none required with some good labeling?
2
Answers
When it comes to ARIA, as I see it, this is an untypical Combobox if the value remains in the input:
value="Zebra, Zoom"
The pattern is established and supported by assistive technology, and makes it clear for users of assistive technology that they need to pick options, but that an additional input helps them find (filter) options.
Contrary to the typical combobox, the associated
listbox
is permanently visible, so the state is notcollapsed
butexpanded
.The ARIA standard lists such a pattern in Example 9.
The required ARIA attributes for the
<input>
are:aria-expanded="true"
alwaysaria-controls="id-of-the-listbox"
aria-autocomplete="list"
to explain that a list of suggestions is providedAnd those for the
listbox
:role="listbox"
, obviouslyaria-labelledby="id-of-the-label"
to provide the required accessible namerole="option"
on the childrenrole="group"
, if grouping options is of interestHere’s the trimmed code from the ARIA example.
As both elements (the input and the list) are within one ARIA widget (or pattern), no
<fieldset>
is necessary.Keyboard navigation
Especially since the list is very long, as you mention, you definitely should manage focus, i.e. have only one focus stop, and pick options with arrow keys.
The popup element in this case is the
listbox
.Otherwise, keyboard users need to step through all the option elements to continue on the page. This would fail WCAG’s Success Criterion Bypass Blocks.
If you don’t want to manage focus, you might add a skip link before the listbox:
Better hide the listbox if it’s long
If the list is, as you mention, very long, it should be hidden by default.
In that case, you are using the most established combobox pattern, which is well-documented in the APG.
aria-expanded
needs to be managed