-
Notifications
You must be signed in to change notification settings - Fork 5
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
fix(chips): use built-in radiogroup / checkbox behavior for a11y #890
Conversation
71d4139
to
b8d61b5
Compare
@jonaskuske great catch, and thanks a lot especially for your comprehensive research and explanations as well as providing the results in code as well already. kudos to you !! |
@jonaskuske what do you think about using |
@mfranzke Apparently using The fix is to set |
e247478
to
ed3e741
Compare
* fix(chips): add focus styles, make input focusable & expose label * chore(chips): remove html lint ignores, add label for single-chip entry in patternlab * Update chip.scss --------- Co-authored-by: Maximilian Franzke <[email protected]>
Chips are composed of a
checkbox
/radio
input and a label. As of now, the input is hidden entirely from screenreaders viadisplay: none
and the label hasrole=button
,aria-hidden=true
and is focusable viatabindex=0
, though the latter is only true in thecore
examples, not indb-ui/elements
*.Problems:
click
despite the missing keyboard event handlers. But I'm not sure if all screenreaders do this (I only tested with Windows Narrator), and also this means interaction via keyboard is inconsistent and works with an active screenreader, but doesn't work without oneSuggestion
I'd suggest to keep radiogroup (interactiontype=selection) or group (interactiontype=filter) semantics for a set of chips, which is achieved by keeping the input in the a11y tree as the focusable element (only hide it visually) and using the label for the visual style. This way:
core
andelements
Recommended usage:
Downsides:
Filter and selection chips visually look the same, but are controlled differently: filter chips are a group of checkboxes, meaning the chips can be individually navigated to through Tab and then activated through space/enter, and selection chips are a radiogroup, where the whole group is navigated to through Tab, and then you can switch between the options with the arrow keys. But that's just using built-in radiogroup and checkbox semantics and is announced as such, so I think that's okay?
Alternatives considered:
listbox
with custom event handlers,aria-selected
state etc.this.click()
and makelabel[role=button"]
focusable in db-ui/elements, tooThe first is a lot of effort and with the second the elements still lack selected state and other relevant info.
fix #694
fix #13
Related: db-ui/elements#2659