fix(a11y): drop invalid aria-required from DateRangeInput trigger button - #4704
Closed
alex-js-ltd wants to merge 3 commits into
Closed
fix(a11y): drop invalid aria-required from DateRangeInput trigger button#4704alex-js-ltd wants to merge 3 commits into
alex-js-ltd wants to merge 3 commits into
Conversation
… button role aria-required is not a supported attribute for role="button" per the ARIA spec (WCAG 4.1.2, axe: aria-allowed-attr) — it's meant for editable/selectable widget roles like textbox or combobox, not activation controls. The trigger button in DateRangeInput hardcodes aria-required when isRequired is true, which is invalid. Replaces the existing test that asserted this buggy behavior as correct, and adds a companion test confirming the required state still reaches assistive tech via the trigger's accessible name. Both currently fail; the fix follows in a separate commit.
aria-required is not a supported attribute for role="button" (the trigger's implicit role) — it's defined for editable/selectable widget roles like textbox or combobox, not activation controls. The trigger hardcoded it whenever isRequired was true, an aria-allowed-attr violation (WCAG 4.1.2) flagged in facebook#4681 against the Required story. The required state now folds into the trigger's accessible name (aria-label) instead, reusing the same "Required" word the visible Field label already shows, so the information isn't lost — just moved somewhere legal for the role.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…bel attribute toHaveAccessibleName computes the actual accessible name the same way assistive tech does, so the test verifies the real contract (what gets announced) rather than pinning to aria-label as the specific mechanism. A future change to aria-labelledby or a native <label> association would still pass; a raw attribute check would not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
DateRangeInput's trigger button hardcodedaria-required="true"whenisRequiredis set, but the trigger is a plain<button>— implicitrole="button", which does not supportaria-required. That attribute is only valid on editable/selectable widget roles (textbox,combobox,listbox, etc.), not activation controls.Critical
aria-allowed-attrviolation (WCAG 4.1.2), flagged in #4681 against 1/18DateRangeInputstories (Required).Solution
Removed
aria-requiredfrom the trigger button. The required state now folds into the button'saria-labelinstead (e.g."Range: Select date range, Required"), reusing the same@astryx.field.requiredtranslation string the visibleFieldlabel already shows — so the information isn't dropped, just moved somewhere legal for the role.Verification
1 resolved =
DateRangeInput::Required::aria-allowed-attr, matching #4681 exactly.DateRangeInput+Fieldsuites (125 tests) + typecheck passa11y:auditgate passes, 0 new violationspatch)Addresses part of #4681 (the
aria-allowed-attrfinding onDateRangeInputonly).