Skip to content

fix(a11y): drop invalid aria-required from DateRangeInput trigger button - #4704

Closed
alex-js-ltd wants to merge 3 commits into
facebook:mainfrom
alex-js-ltd:fix/date-range-input-aria-allowed-attr
Closed

fix(a11y): drop invalid aria-required from DateRangeInput trigger button#4704
alex-js-ltd wants to merge 3 commits into
facebook:mainfrom
alex-js-ltd:fix/date-range-input-aria-allowed-attr

Conversation

@alex-js-ltd

Copy link
Copy Markdown

Problem

DateRangeInput's trigger button hardcoded aria-required="true" when isRequired is set, but the trigger is a plain <button> — implicit role="button", which does not support aria-required. That attribute is only valid on editable/selectable widget roles (textbox, combobox, listbox, etc.), not activation controls.

<!-- Before -->
<button aria-required="true">

<!-- After -->
<button>

Critical aria-allowed-attr violation (WCAG 4.1.2), flagged in #4681 against 1/18 DateRangeInput stories (Required).

Solution

Removed aria-required from the trigger button. The required state now folds into the button's aria-label instead (e.g. "Range: Select date range, Required"), reusing the same @astryx.field.required translation string the visible Field label already shows — so the information isn't dropped, just moved somewhere legal for the role.

Verification

pnpm a11y:audit -- --components DateRangeInput
0 new, 0 baselined, 1 resolved, 225 baselined for components outside this run
No new accessibility violations. Gate passed.

1 resolved = DateRangeInput::Required::aria-allowed-attr, matching #4681 exactly.

  • Regression test added, confirmed red → green
  • Full DateRangeInput + Field suites (125 tests) + typecheck pass
  • a11y:audit gate passes, 0 new violations
  • Changeset added (patch)

Addresses part of #4681 (the aria-allowed-attr finding on DateRangeInput only).

… 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.
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 4, 2026 1:25pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 4, 2026
…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.
@alex-js-ltd alex-js-ltd closed this Aug 4, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant