Skip to content

[test][form label] Add axe tests and WCAG conformance report - #49552

Open
michelengelen wants to merge 2 commits into
mui:masterfrom
michelengelen:feature/mat-2024-a11yformlabel-assess-wcag-22-conformance
Open

michelengelen wants to merge 2 commits into
mui:masterfrom
michelengelen:feature/mat-2024-a11yformlabel-assess-wcag-22-conformance

Conversation

@michelengelen

@michelengelen michelengelen commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Adds axe coverage, WCAG unit tests, and a WCAG 2.2 Level A/AA conformance report for FormLabel. This is Wave 1, item 6 of #49260. Part of #49410.

FormLabel

Result Count
✅ Supports 11
⚠️ Partially Supports 2
❌ Does Not Support 0
➖ Not Applicable 42
🚩 Flagged 3/13

Known gaps:

  • 1.3.1 Info and Relationships. On a required group legend, the asterisk is aria-hidden. Checkbox, Radio, and Switch do not take required from FormControl, and RadioGroup has no required prop, so assistive technology gets no required state. FormLabel owns this gap. A unit test pins it for Checkbox.
  • 1.4.3 Contrast (Minimum). A focused label takes the main color of its field: info (3.86:1) and warning (3.11:1) fail in light mode. In dark mode, the error label falls below 4.5:1 on a Paper with elevation 2 or more, such as a Menu or Dialog (4.30:1 at elevation 2, 3.13:1 at elevation 24). The elevation overlay lightens the surface.

Report: FormLabel/accessibility.md

Changes

  • Tests. The FormLabel.test.js "WCAG 2.2 conformance" block covers:
    • 1.3.1: component="legend" renders a legend element that names the fieldset group. htmlFor is forwarded as the for attribute. A Checkbox does not get required from FormControl (documented gap).
    • 1.4.3: the focused colors, compared with the palette contrast contract. A tripwire test computes dark error.main over the elevation overlay at elevation 2 and 24, and asserts both are below 4.5:1.
    • 2.5.3: the hidden asterisk adds nothing to the name.
    • 3.3.2: the label shows the asterisk, and an Input gets required from FormControl.
  • axe. FormLabel has no docs page, so it follows the pattern of [test][FormControlLabel] Add axe tests and WCAG conformance report #49524: three fixtures own a new form-label slug, with a docs folder that holds only form-label.a11y.json.
    • FormLabelA11yStates and FormLabelA11yColorMatrixDark assert every rule.
    • FormLabelA11yColorMatrix records the light-mode color-contrast failure without asserting it.
  • Playwright. FormLabel is in the CSS layout suite on its states fixture.
  • Known gaps.
    • New row for 1.3.1: "A required checkbox, radio, or switch group exposes no required state to assistive technology". The workaround includes required on FormControlLabel, which forwards it to its control.
    • FormLabel is added to the palette row, for focused info and warning.
    • New library row for 1.4.3, right after the palette row: in dark mode, the elevation overlay lowers error text below 4.5:1 on a Paper with elevation 2 or more. It affects FormLabel and TextField. Another PR adds the same row text with a different affected list. Merge the two lists when both land.
  • TextField report. The 1.4.3 region, gap line, and pass condition now include dark-mode error text on elevated Paper. The rating stays Partially Supports.
  • RadioGroup report. The 3.3.1 N/A reason said that RadioGroup "supports required". RadioGroup has no required prop. The text now says to set aria-required="true" on the RadioGroup.
  • Docs page. The hard-coded component count and the "Five issues" count are removed, with the same text as the other Wave 1 PRs.

Decisions for review

The Form* reports now use these team rating rules:

  • R1: rate a criterion only if the component renders what it governs. R2: rate text criteria only for text of its own. R3: rate 4.1.2 and 2.5.3 only if the component sets a role or supplies a name. R4: 3.2.4 is N/A for non-interactive parts.
  • R5: responsibility is Component when the component sets the value. R6: a decorative glyph that duplicates a native state does not trigger 1.1.1. R7: one root cause gets one ⚠️, on the component that creates it. R8: a test is evidence only if it fails when the output of the component regresses.

Decisions for FormLabel:

  • The focus, keyboard, and pointer criteria are Not Applicable. The label is not focusable. A label with htmlFor adds its area to the target of its field, so the field report rates 2.5.2 and 2.5.8.
  • 3.2.4 is Not Applicable (R4). The label is not interactive. Each control report rates 3.2.4 for the control and its label. This agrees with [test][FormControlLabel] Add axe tests and WCAG conformance report #49524 for FormControlLabel.
  • 1.1.1 is Not Applicable (R6). The asterisk is decorative and duplicates the native required state, as in TextField. On a group legend, nothing duplicates it, so the gap is rated under 1.3.1.
  • FormLabel owns the required-group gap (R7). The Checkbox gap test moved from 3.3.2 to 1.3.1. 3.3.2 stays Supports with a cross-link.
  • The 3.3.2 manual steps use the workaround. Step 1 sets aria-required="true" on the RadioGroup, because the pass condition fails without it.
  • A disabled label is exempt when its field is disabled, because it is part of an inactive component.
  • 4.1.2 and 2.5.3 are rated, because the label provides the name of the field.

Merge order with the sibling Wave 1 PRs

Do not hand-merge the generated blocks: after each rebase, run pnpm a11y:scorecard. knownGaps.json, demoMeta.ts, demoMeta.test.ts, and criteriaSuites.mjs conflict with the other Wave 1 PRs as adjacent insertions.

Not done in this PR

  • The screen-reader checks from the issue have steps and pass conditions in the report. Nobody has run them yet.

Follow-ups (tracked in #49477)

  • Component: expose the required state of a group. Until then, document aria-required on RadioGroup, required on a single Checkbox or Switch, and the legend text for a checkbox group.
  • The TextField report lists only warning for the focused label. InputLabel uses the FormLabel styles, so focused info fails too.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@code-infra-dashboard

code-infra-dashboard Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Performance

No regressions in 32 benchmarks · ran 4m 00s · details


Check out the code infra dashboard for more information about this PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant