Daily Accessibility ReviewCheckbox component: aria-checked incorrectly uses !!value instead of isChecked #17798
Unanswered
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
The custom
Checkboxcomponent (pkg/rancher-components/src/components/Form/Checkbox/Checkbox.vue) setsaria-checked="!!value"on therole="checkbox"span. This is incorrect when the checkbox uses an array value or a customvalueWhenTrue, because!!valueevaluates truthiness of the raw prop rather than the actual checked state. Screen readers will announce the wrong checked state.WCAG 2.2 Violation
aria-checkedmust reflect the actual state, not a truthy coercion of the raw value.Relevant Code
pkg/rancher-components/src/components/Form/Checkbox/Checkbox.vue, line 305:The component already computes
isCheckedcorrectly (line 171–173):How the Bug Manifests
valuepropvalueWhenTrue!!valueisChecked[](empty array)truetrue(array is truthy!)false✅['other']'mine'truefalse✅falsetruefalsefalse✅truetruetruetrue✅When using an array value or a custom
valueWhenTrue,aria-checkedwill reporttruewhile the checkbox is visually unchecked.Suggested Fix
Replace
!!valuewith the computedisCheckedproperty:Steps to Reproduce
Use the checkbox in multi-value mode (pass an empty array as
value) and inspectaria-checkedwith a screen reader or DevTools — it will reporttruedespite the checkbox being unchecked.Beta Was this translation helpful? Give feedback.
All reactions