a11y: triggering element cannot contain interactive elements #273
Labels
auro-dropdown
not-reviewed
Issue has not been reviewed by Auro team members
Type: Bug
Bug or Bug fixes
Please verify the version of auro-dropdown you have installed
@latest
Please describe the bug
See code
auro-dropdown/src/auro-dropdown.js
Lines 473 to 491 in 57c991b
In the current implementation of the dropdown UI, the
div
container has[role="button"]
effectively redefining thediv
to be a<button>
element. This is problematic because the content in thetrigger
slot can be any HTML, including interactive elements likeinput
,button
, orselect
. See the DOM output of theauro-combobox
element.In any scenario where there is an interactive element placed within the scope of any element
*[role="button"]
is similar to adding interactive content within a<button>
element and would be considered non-compliant.<button>
and<input>
are interactive elements with distinct behaviors<button>
is not intended to contain focusable, interactive elements like<input>
. Nesting breaks the semantic meaning of the<button>
, confusing assistive technologies and users.<button>
as "button," but they won't know how to handle the nested<input>
.Reproducing the error
This issue is reproducible on the Auro docsite
Recommendation
The root cause of the issue lies in the fact that
auro-dropdown
, appropriately so, attempts to manage the accessibility state of the popup content. However, in a scenario where the triggering element of the UI is interactive, the responsibility for managing this state should be delegated to the child element. In this instance,auro-input
.An update to
auro-dropdown
would be to consider the following:role="button"
is optional allowing the consumer some control over the interactive state of thetrigger
element.role="button"
to thename="trigger"
slot
element (see example)Moving the accessibility attributes like
aria-expanded
to the<slot name="trigger">
where the<input>
resides, and makingrole="button"
optional, would simplify the structure and improve semantic clarity. Removingrole="button"
is only applicable provided that the<input>
(or the slotted content) becomes the actual trigger element.Example
What browsers are you seeing the problem on?
Firefox, Chrome, Safari, Microsoft Edge
Additional context
This issue is related to an accessibility finding: https://alaskaair.hub.essentia11y.com/projects/6759ec2bc0afd4c33f103b81/tasks/6765ecf582f50344673fac0a?linkedPropertyData=652813da6eec28e13de119c4%7C652813da6eec28ef1ee119bd
Exit criteria
This issue can be closed one the updated
auro-dropdown
ensures proper accessibility and semantic integrity by dynamically delegating responsibility for interactive behaviors and accessibility states to the appropriate element. It should:role="button"
.<input>
or<button>
).The text was updated successfully, but these errors were encountered: