Skip to content

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

Merged
michelengelen merged 12 commits into
mui:masterfrom
michelengelen:feature/mat-2024-a11yformlabel-assess-wcag-22-conformance
Nov 27, 2026
Merged

michelengelen merged 12 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. Unit tests pin it for Checkbox, Radio, Switch, and RadioGroup.
  • 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 (about 4.3:1 at elevation 2, 3.14:1 at elevation 24). The elevation overlay lightens the surface. At elevation 1, the label is about 4.5:1, which is borderline.

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. Checkbox, Radio, and Switch do not get required from FormControl, and RadioGroup gets no aria-required (documented gap).
    • 1.4.3: the focused colors, compared with the palette contrast contract. A second test renders the error label in a dark Paper at elevation 1, 2, and 24. It blends the computed overlay of the Paper with its background color, and measures the label against the result. It asserts a ratio from 4.5:1 to 4.6:1 at elevation 1, and less than 4.5:1 at elevation 2 and 24. This test runs only in the browser test projects.
    • 2.5.3: the accessible name of the field is the visible label. The existing "prop: required" tests confirm that the asterisk is hidden.
    • 3.3.2 has no new test. The report cites the existing tests: "required should show an asterisk" in FormLabel.test.js, and "required" in InputBase.test.js.
  • 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, and for error on a dark Paper with elevation 2 or more. There is no separate dark-mode row.
    • In the palette row, Button gets the note "info, warning; error in dark mode". The workaround now includes the dark-mode fix: a lighter error.main, or a surface with elevation 0 or 1. It also says that elevation does not help the label of a filled TextField. [test][form helper text] Add axe tests and WCAG conformance report #49553 makes the same two edits.
  • TextField report. The 1.4.3 region, gap line, and pass condition now include dark-mode error text. Error text falls short on a Paper with elevation 2 or more. The filled error label falls short at every elevation (about 4.04:1 at elevation 0). The rating stays Partially Supports. [test][form helper text] Add axe tests and WCAG conformance report #49553 makes the identical edit.
  • Button report. The 1.4.3 gap line, section, manual steps, and pass condition now include dark-mode error. The contained label is 3.68:1 on every surface. The text and outlined labels fall short on a Paper with elevation 2 or more. [test][form helper text] Add axe tests and WCAG conformance report #49553 makes the identical edit.
  • 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.
  • Back links. The Checkbox, Radio, Switch, and RadioGroup reports each get one bullet that links to the FormLabel gap.

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 gap tests for Checkbox, Radio, Switch, and RadioGroup are under 1.3.1. The reports of these components keep their ratings and link to the FormLabel gap. 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

This branch includes master, with the IconButton PR (#49549) and the Link PR (#49555). 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. #49553 edits the same palette row in knownGaps.json: keep the FormLabel entry and the FormHelperText entry.

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 · precise to ±10.2% (±13.3% at worst) · ran 3m 43s · details


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

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

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

@siriwatknp siriwatknp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran pnpm a11y:scorecard:check on this head and on a trial merge with latest master. Both are up to date.

Two things to settle before merge, the dark-mode contrast test and which component owns the required-group gap. Both are inline.

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 26, 2026
…rmance

Keep both sides in knownGaps.json, where the IconButton PR (mui#49549) also adds rows. Take the lockfile from master. Regenerate the scorecard files with pnpm a11y:scorecard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 27, 2026
…rmance

Master now has the Link PR (mui#49555). Keep both sides in knownGaps.json. Regenerate the scorecard files with pnpm a11y:scorecard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions github-actions Bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Nov 27, 2026
michelengelen added a commit to michelengelen/material-ui that referenced this pull request Nov 27, 2026
The known-gaps note for Button names error in dark mode, but the Button report listed only info and warning. Add the dark-mode values to the 1.4.3 gap, section, manual steps, and pass condition. mui#49552 makes the identical edit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@michelengelen
michelengelen enabled auto-merge (squash) November 27, 2026 09:46
@michelengelen
michelengelen merged commit 3079e4c into mui:master Nov 27, 2026
23 checks passed
@michelengelen
michelengelen deleted the feature/mat-2024-a11yformlabel-assess-wcag-22-conformance branch November 27, 2026 10:36
michelengelen added a commit to michelengelen/material-ui that referenced this pull request Nov 27, 2026
Master now has the FormLabel PR (mui#49552). Keep both sides in the files that it also edits. Regenerate the scorecard files with pnpm a11y:scorecard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
michelengelen added a commit to michelengelen/material-ui that referenced this pull request Nov 27, 2026
…formance

Master now has the FormLabel PR (mui#49552). Keep both sides in the files that it also edits. Regenerate the scorecard files with pnpm a11y:scorecard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
michelengelen added a commit to michelengelen/material-ui that referenced this pull request Nov 27, 2026
…conformance

Master now has the FormLabel PR (mui#49552). Keep both sides in the files that it also edits. Regenerate the scorecard files with pnpm a11y:scorecard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
michelengelen added a commit to michelengelen/material-ui that referenced this pull request Nov 27, 2026
…rmance

Master now has the FormLabel PR (mui#49552). Keep both sides in the files that it also edits. Regenerate the scorecard files with pnpm a11y:scorecard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
michelengelen added a commit to michelengelen/material-ui that referenced this pull request Nov 27, 2026
Master now has the FormLabel PR (mui#49552). Keep both sides in the files that it also edits. Regenerate the scorecard files with pnpm a11y:scorecard.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
michelengelen added a commit to JCQuintas/material-ui that referenced this pull request Nov 27, 2026
Master now has the dark-mode error text in the Button 1.4.3 section, from mui#49552. Keep both texts in the gap line and in the section.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.

3 participants