button with role="combobox" is not considered valid when referenced from a label element #4235
Closed
1 task done
Labels
ungroomed
Ticket needs a maintainer to prioritize and label
Product
axe-core
Product Version
4.8.2
Latest Version
Issue Description
We have recently implemented a combobox component (similar to what's described in https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/).
The component's raw HTML looks something like this:
When we evaluate this with
axe-core
, it gets marked as invalid with this violation:If we remove the
role="combobobx"
attribute, or addaria-label
oraria-labelledby
attributes, then axe-core considers it valid.However, this document suggests linking the combobox button with a label should also be valid:
(Our case would be the first one described there).
This other document also indicates buttons are valid targets to be referenced by labels:
In fact, testing the code above with a screen reader has the expected result, in whcih the label is read, followed by the button content, and the fact that it's linked to a listbox.
Removing the
role="combobobx"
attribute has other side effects, in which screen readers no longer announce the label.Expectation
axe-core marks this as valid, as long as the toggle button has at least one of
aria-label
,aria-labelledby
or a<label />
referencing to it.Actual
axe-core considers this invalid when neither
aria-label
oraria-labelledby
are provided, even if referenced from a<label />
element.How to Reproduce
Pass the first html snippet above to axe-core.
Running this html file in a browser you'll get the violation mentioned above console-logged:
Additional context
N/A
The text was updated successfully, but these errors were encountered: