diff --git a/docs/data/material/components/floating-action-button/floating-action-button.a11y.json b/docs/data/material/components/floating-action-button/floating-action-button.a11y.json new file mode 100644 index 00000000000000..e2227f7947162e --- /dev/null +++ b/docs/data/material/components/floating-action-button/floating-action-button.a11y.json @@ -0,0 +1,282 @@ +{ + "FabA11yColorMatrix": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-hidden-focus": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-prohibited-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr-value": { + "status": "pass", + "tags": ["wcag2a"] + }, + "button-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "color-contrast": { + "status": "fail", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "FabA11yLongLabel": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-hidden-focus": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-prohibited-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr-value": { + "status": "pass", + "tags": ["wcag2a"] + }, + "button-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "color-contrast": { + "status": "incomplete", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "FabA11ySemanticStates": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-command-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-deprecated-role": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-hidden-focus": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-prohibited-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-required-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-roles": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr-value": { + "status": "pass", + "tags": ["wcag2a"] + }, + "button-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "link-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "FloatingActionButtonExtendedSize": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-hidden-focus": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-prohibited-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr-value": { + "status": "pass", + "tags": ["wcag2a"] + }, + "button-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "FloatingActionButtons": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-hidden-focus": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-prohibited-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr-value": { + "status": "pass", + "tags": ["wcag2a"] + }, + "button-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "FloatingActionButtonSize": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-hidden-focus": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-prohibited-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-valid-attr-value": { + "status": "pass", + "tags": ["wcag2a"] + }, + "button-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + } +} diff --git a/docs/data/material/getting-started/accessibility/accessibility.md b/docs/data/material/getting-started/accessibility/accessibility.md index aed3247922e908..a4cb9a8550815e 100644 --- a/docs/data/material/getting-started/accessibility/accessibility.md +++ b/docs/data/material/getting-started/accessibility/accessibility.md @@ -39,10 +39,11 @@ Each row counts only the criteria that **apply** to that component; criteria tha | :------------------------------------------------------------------------------------------------------------------------------- | ------: | -------: | ----: | ----------: | --------------------: | -------: | --------: | | [Accordion](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Accordion/accessibility.md) | 11 | 8 | 19 | 19 | 0 | 16/19 | 9 | | [AccordionSummary](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/AccordionSummary/accessibility.md) | 13 | 11 | 24 | 23 | 1 | 21/24 | 11 | -| [Avatar](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Avatar/accessibility.md) | 5 | 6 | 11 | 9 | 2 | 6/11 | 2 | +| [Avatar](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Avatar/accessibility.md) | 5 | 6 | 11 | 9 | 2 | 7/11 | 3 | | [Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) | 16 | 12 | 28 | 23 | 5 | 19/28 | 10 | | [Checkbox](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Checkbox/accessibility.md) | 14 | 11 | 25 | 24 | 1 | 22/25 | 11 | | [CircularProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CircularProgress/accessibility.md) | 6 | 5 | 11 | 8 | 3 | 6/11 | 1 | +| [Fab](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Fab/accessibility.md) | 14 | 11 | 25 | 21 | 4 | 19/25 | 9 | | [FormLabel](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/FormLabel/accessibility.md) | 7 | 6 | 13 | 11 | 2 | 10/13 | 4 | | [IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) | 15 | 12 | 27 | 22 | 5 | 18/27 | 9 | | [LinearProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/LinearProgress/accessibility.md) | 6 | 5 | 11 | 8 | 3 | 6/11 | 1 | @@ -60,7 +61,7 @@ Each row counts only the criteria that **apply** to that component; criteria tha **No component records a ❌ Does Not Support rating for any Level A or AA criterion.** -Rolled up to the library level, where each criterion takes the worst rating any assessed component receives, 32 success criteria are exercised: **25 Supports, 7 Partially Supports, 0 Does Not Support.** +Rolled up to the library level, where each criterion takes the worst rating any assessed component receives, 32 success criteria are exercised: **23 Supports, 9 Partially Supports, 0 Does Not Support.** @@ -87,16 +88,17 @@ Each ⚠️ rating comes from one of the issues below. Some of them can be fixed -| Gap | Criteria | Affected | Workaround | -| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **By default, the keyboard focus indicator is the ripple or a background tint, and its contrast can fall below 3:1** | [1.4.11 Non-text Contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html) | [AccordionSummary](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/AccordionSummary/accessibility.md)
[Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md)
[Checkbox](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Checkbox/accessibility.md)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (the ring needs `disableFocusRipple` too)
[Radio](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Radio/accessibility.md)
[Switch](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Switch/accessibility.md)
[ToggleButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButton/accessibility.md) | Enable `focusVisible` in your theme — see below | -| **Some default palette colors fall short of contrast minimums** | [1.4.3 Contrast (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html)
[1.4.11 Non-text Contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html) | [Avatar](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Avatar/accessibility.md)
[Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) (`info`, `warning`; `error` in dark mode)
[CircularProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CircularProgress/accessibility.md) (`warning` with `enableTrackSlot`)
[FormLabel](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/FormLabel/accessibility.md) (focused `info`, `warning`; `error` on a dark Paper with elevation 2 or more)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (`info`, `warning`)
[LinearProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/LinearProgress/accessibility.md)
[Link](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Link/accessibility.md) (link text, 1.4.3 only)
[Switch](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Switch/accessibility.md)
[TextField](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/TextField/accessibility.md)
[ToggleButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButton/accessibility.md) | Override the affected palette entries. In dark mode, set a lighter `error.main`, or keep `error` text on a surface with elevation 0 or 1. Elevation does not help the label of a `filled` TextField | -| **The selected state of colored Toggle Buttons is conveyed almost entirely by hue** | [1.4.1 Use of Color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html) | [ToggleButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButton/accessibility.md) (`primary`, `error`, `info`, `success`) | Add a non-color cue to the selected state, such as an icon | -| **A required checkbox, radio, or switch group exposes no required state to assistive technology, because Checkbox, Radio, and Switch do not take `required` from FormControl and RadioGroup has no `required` prop** | [1.3.1 Info and Relationships](https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html) | [FormLabel](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/FormLabel/accessibility.md) (`required` group legend) | Set `aria-required` on a RadioGroup. Set `required` on a single Checkbox or Switch, or on its FormControlLabel, which forwards it to the control. For a checkbox group, state the requirement in the legend text | -| **Links without an underline rely on color, and several link colors are below 3:1 against body text** | [1.4.1 Use of Color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html) | [Link](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Link/accessibility.md) (`underline="none"`, `underline="hover"`) | Keep the default `underline="always"` for links in body text | -| **Dynamic state changes are not announced** | [4.1.3 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html) | [Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) (`loading`)
[CircularProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CircularProgress/accessibility.md)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (`loading`)
[LinearProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/LinearProgress/accessibility.md)
[TextField](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/TextField/accessibility.md) (error) | Render your own `aria-live` region alongside | -| **Indefinite animation cannot be paused** | [2.2.2 Pause, Stop, Hide](https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html) | [Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) (`loading`)
[CircularProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CircularProgress/accessibility.md) (`indeterminate`)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (`loading`)
[LinearProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/LinearProgress/accessibility.md) (`indeterminate`, `query`, `buffer`) | Show it only while an operation is in flight | -| **A focused button that turns `loading` loses keyboard focus to the page** | [2.4.3 Focus Order](https://www.w3.org/WAI/WCAG22/Understanding/focus-order.html) | [Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) (`loading`)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (`loading`) | Move focus to a nearby element before you set `loading`, and back when it ends | +| Gap | Criteria | Affected | Workaround | +| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **By default, the keyboard focus indicator is the ripple or a background tint, and its contrast can fall below 3:1** | [1.4.11 Non-text Contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html) | [AccordionSummary](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/AccordionSummary/accessibility.md)
[Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md)
[Checkbox](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Checkbox/accessibility.md)
[Fab](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Fab/accessibility.md) (the ring needs `disableFocusRipple`)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (the ring needs `disableFocusRipple` too)
[Radio](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Radio/accessibility.md)
[Switch](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Switch/accessibility.md)
[ToggleButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButton/accessibility.md) | Enable `focusVisible` in your theme — see below | +| **Some default palette colors fall short of contrast minimums** | [1.4.3 Contrast (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/contrast-minimum.html)
[1.4.11 Non-text Contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html) | [Avatar](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Avatar/accessibility.md)
[Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) (`info`, `warning`; `error` in dark mode)
[CircularProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CircularProgress/accessibility.md) (`warning` with `enableTrackSlot`)
[Fab](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Fab/accessibility.md) (`info`, `warning`; label on the focus ripple: use `disableFocusRipple` with the ring)
[FormLabel](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/FormLabel/accessibility.md) (focused `info`, `warning`; `error` on a dark Paper with elevation 2 or more)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (`info`, `warning`)
[LinearProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/LinearProgress/accessibility.md)
[Link](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Link/accessibility.md) (link text, 1.4.3 only)
[Switch](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Switch/accessibility.md)
[TextField](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/TextField/accessibility.md)
[ToggleButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButton/accessibility.md) | Override the affected palette entries. In dark mode, set a lighter `error.main`, or keep `error` text on a surface with elevation 0 or 1. Elevation does not help the label of a `filled` TextField | +| **The selected state of colored Toggle Buttons is conveyed almost entirely by hue** | [1.4.1 Use of Color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html) | [ToggleButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButton/accessibility.md) (`primary`, `error`, `info`, `success`) | Add a non-color cue to the selected state, such as an icon | +| **The extended Fab has a fixed height, so a label that wraps can spill out of it** | [1.4.10 Reflow](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html)
[1.4.12 Text Spacing](https://www.w3.org/WAI/WCAG22/Understanding/text-spacing.html) | [Fab](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Fab/accessibility.md) (`extended`) | Keep labels short, or set `height: 'auto'`, `minHeight: 48`, and vertical padding with `sx` | +| **A required checkbox, radio, or switch group exposes no required state to assistive technology, because Checkbox, Radio, and Switch do not take `required` from FormControl and RadioGroup has no `required` prop** | [1.3.1 Info and Relationships](https://www.w3.org/WAI/WCAG22/Understanding/info-and-relationships.html) | [FormLabel](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/FormLabel/accessibility.md) (`required` group legend) | Set `aria-required` on a RadioGroup. Set `required` on a single Checkbox or Switch, or on its FormControlLabel, which forwards it to the control. For a checkbox group, state the requirement in the legend text | +| **Links without an underline rely on color, and several link colors are below 3:1 against body text** | [1.4.1 Use of Color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html) | [Link](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Link/accessibility.md) (`underline="none"`, `underline="hover"`) | Keep the default `underline="always"` for links in body text | +| **Dynamic state changes are not announced** | [4.1.3 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html) | [Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) (`loading`)
[CircularProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CircularProgress/accessibility.md)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (`loading`)
[LinearProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/LinearProgress/accessibility.md)
[TextField](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/TextField/accessibility.md) (error) | Render your own `aria-live` region alongside | +| **Indefinite animation cannot be paused** | [2.2.2 Pause, Stop, Hide](https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html) | [Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) (`loading`)
[CircularProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CircularProgress/accessibility.md) (`indeterminate`)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (`loading`)
[LinearProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/LinearProgress/accessibility.md) (`indeterminate`, `query`, `buffer`) | Show it only while an operation is in flight | +| **A focused button that turns `loading` loses keyboard focus to the page** | [2.4.3 Focus Order](https://www.w3.org/WAI/WCAG22/Understanding/focus-order.html) | [Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) (`loading`)
[IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) (`loading`) | Move focus to a nearby element before you set `loading`, and back when it ends | diff --git a/docs/data/material/getting-started/accessibility/knownGaps.json b/docs/data/material/getting-started/accessibility/knownGaps.json index 90214427fc37ff..4c80a5873b505e 100644 --- a/docs/data/material/getting-started/accessibility/knownGaps.json +++ b/docs/data/material/getting-started/accessibility/knownGaps.json @@ -6,6 +6,7 @@ "AccordionSummary", "Button", "Checkbox", + { "component": "Fab", "note": "the ring needs `disableFocusRipple`" }, { "component": "IconButton", "note": "the ring needs `disableFocusRipple` too" }, "Radio", "Switch", @@ -20,6 +21,10 @@ "Avatar", { "component": "Button", "note": "`info`, `warning`; `error` in dark mode" }, { "component": "CircularProgress", "note": "`warning` with `enableTrackSlot`" }, + { + "component": "Fab", + "note": "`info`, `warning`; label on the focus ripple: use `disableFocusRipple` with the ring" + }, { "component": "FormLabel", "note": "focused `info`, `warning`; `error` on a dark Paper with elevation 2 or more" @@ -39,6 +44,12 @@ "affected": [{ "component": "ToggleButton", "note": "`primary`, `error`, `info`, `success`" }], "workaround": "Add a non-color cue to the selected state, such as an icon" }, + { + "gap": "The extended Fab has a fixed height, so a label that wraps can spill out of it", + "criteria": ["1.4.10", "1.4.12"], + "affected": [{ "component": "Fab", "note": "`extended`" }], + "workaround": "Keep labels short, or set `height: 'auto'`, `minHeight: 48`, and vertical padding with `sx`" + }, { "gap": "A required checkbox, radio, or switch group exposes no required state to assistive technology, because Checkbox, Radio, and Switch do not take `required` from FormControl and RadioGroup has no `required` prop", "criteria": ["1.3.1"], diff --git a/docs/data/material/getting-started/accessibility/scorecard.json b/docs/data/material/getting-started/accessibility/scorecard.json index ff88135f38f96a..03f86acc6ababd 100644 --- a/docs/data/material/getting-started/accessibility/scorecard.json +++ b/docs/data/material/getting-started/accessibility/scorecard.json @@ -1,12 +1,12 @@ { "standard": "WCAG 2.2 Level A and AA", - "componentCount": 16, + "componentCount": 17, "totals": { "rated": 32, - "supports": 25, - "partiallySupports": 7, + "supports": 23, + "partiallySupports": 9, "doesNotSupport": 0, - "flagged": 15 + "flagged": 14 }, "criteria": [ { @@ -66,6 +66,7 @@ "affected": [ "Avatar", "Button", + "Fab", "FormLabel", "IconButton", "Link", @@ -78,7 +79,7 @@ "name": "Resize Text", "level": "AA", "conformance": "Supports", - "flagged": true, + "flagged": false, "affected": [] }, { @@ -93,9 +94,9 @@ "number": "1.4.10", "name": "Reflow", "level": "AA", - "conformance": "Supports", + "conformance": "Partially Supports", "flagged": false, - "affected": [] + "affected": ["Fab"] }, { "number": "1.4.11", @@ -109,6 +110,7 @@ "Button", "Checkbox", "CircularProgress", + "Fab", "IconButton", "LinearProgress", "Radio", @@ -121,9 +123,9 @@ "number": "1.4.12", "name": "Text Spacing", "level": "AA", - "conformance": "Supports", + "conformance": "Partially Supports", "flagged": false, - "affected": [] + "affected": ["Fab"] }, { "number": "2.1.1", @@ -743,7 +745,7 @@ "partiallySupports": 2, "doesNotSupport": 0, "notApplicable": 44, - "flagged": 5, + "flagged": 4, "rated": 11 }, "gaps": [ @@ -819,8 +821,8 @@ "level": "AA", "conformance": "Supports", "responsibility": "Component", - "group": "Manual", - "flagged": true + "group": "Automated", + "flagged": false }, { "number": "1.4.5", @@ -866,8 +868,8 @@ "supports": 9, "partiallySupports": 2, "doesNotSupport": 0, - "verified": 6, - "automated": 2 + "verified": 7, + "automated": 3 } }, { @@ -1566,6 +1568,276 @@ "automated": 1 } }, + { + "component": "Fab", + "counts": { + "supports": 21, + "partiallySupports": 4, + "doesNotSupport": 0, + "notApplicable": 30, + "flagged": 6, + "rated": 25 + }, + "gaps": [ + { + "number": "1.4.3", + "name": "Contrast (Minimum)", + "conformance": "Partially Supports" + }, + { + "number": "1.4.10", + "name": "Reflow", + "conformance": "Partially Supports" + }, + { + "number": "1.4.11", + "name": "Non-text Contrast", + "conformance": "Partially Supports" + }, + { + "number": "1.4.12", + "name": "Text Spacing", + "conformance": "Partially Supports" + } + ], + "criteria": [ + { + "number": "1.1.1", + "name": "Non-text Content", + "level": "A", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": false + }, + { + "number": "1.3.1", + "name": "Info and Relationships", + "level": "A", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": false + }, + { + "number": "1.3.2", + "name": "Meaningful Sequence", + "level": "A", + "conformance": "Supports", + "responsibility": "Author", + "group": "Manual", + "flagged": true + }, + { + "number": "1.3.3", + "name": "Sensory Characteristics", + "level": "A", + "conformance": "Supports", + "responsibility": "Author", + "group": "Manual", + "flagged": true + }, + { + "number": "1.4.1", + "name": "Use of Color", + "level": "A", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": true + }, + { + "number": "1.4.3", + "name": "Contrast (Minimum)", + "level": "AA", + "conformance": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid", + "flagged": false + }, + { + "number": "1.4.4", + "name": "Resize Text", + "level": "AA", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Automated", + "flagged": false + }, + { + "number": "1.4.5", + "name": "Images of Text", + "level": "AA", + "conformance": "Supports", + "responsibility": "Author", + "group": "Manual", + "flagged": false + }, + { + "number": "1.4.10", + "name": "Reflow", + "level": "AA", + "conformance": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid", + "flagged": false + }, + { + "number": "1.4.11", + "name": "Non-text Contrast", + "level": "AA", + "conformance": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid", + "flagged": true + }, + { + "number": "1.4.12", + "name": "Text Spacing", + "level": "AA", + "conformance": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid", + "flagged": false + }, + { + "number": "2.1.1", + "name": "Keyboard", + "level": "A", + "conformance": "Supports", + "responsibility": "Component", + "group": "Automated", + "flagged": false + }, + { + "number": "2.1.2", + "name": "No Keyboard Trap", + "level": "A", + "conformance": "Supports", + "responsibility": "Component", + "group": "Automated", + "flagged": false + }, + { + "number": "2.4.3", + "name": "Focus Order", + "level": "A", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Automated", + "flagged": false + }, + { + "number": "2.4.4", + "name": "Link Purpose (In Context)", + "level": "A", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": false + }, + { + "number": "2.4.6", + "name": "Headings and Labels", + "level": "AA", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": false + }, + { + "number": "2.4.7", + "name": "Focus Visible", + "level": "AA", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": false + }, + { + "number": "2.4.11", + "name": "Focus Not Obscured (Minimum)", + "level": "AA", + "conformance": "Supports", + "responsibility": "Author", + "group": "Manual", + "flagged": true + }, + { + "number": "2.5.2", + "name": "Pointer Cancellation", + "level": "A", + "conformance": "Supports", + "responsibility": "Component", + "group": "Automated", + "flagged": false + }, + { + "number": "2.5.3", + "name": "Label in Name", + "level": "A", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Automated", + "flagged": false + }, + { + "number": "2.5.8", + "name": "Target Size (Minimum)", + "level": "AA", + "conformance": "Supports", + "responsibility": "Component", + "group": "Automated", + "flagged": false + }, + { + "number": "3.2.1", + "name": "On Focus", + "level": "A", + "conformance": "Supports", + "responsibility": "Component", + "group": "Automated", + "flagged": false + }, + { + "number": "3.2.2", + "name": "On Input", + "level": "A", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Automated", + "flagged": false + }, + { + "number": "3.2.4", + "name": "Consistent Identification", + "level": "AA", + "conformance": "Supports", + "responsibility": "Author", + "group": "Manual", + "flagged": true + }, + { + "number": "4.1.2", + "name": "Name, Role, Value", + "level": "A", + "conformance": "Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": false + } + ], + "summary": { + "rated": 25, + "levelA": 14, + "levelAA": 11, + "supports": 21, + "partiallySupports": 4, + "doesNotSupport": 0, + "verified": 19, + "automated": 9 + } + }, { "component": "FormLabel", "counts": { diff --git a/packages/mui-material/src/Avatar/accessibility.json b/packages/mui-material/src/Avatar/accessibility.json index fcc2cc3d0ece02..b1205e261fc9b7 100644 --- a/packages/mui-material/src/Avatar/accessibility.json +++ b/packages/mui-material/src/Avatar/accessibility.json @@ -6,7 +6,7 @@ "1.3.3": { "flagged": true }, "1.4.1": { "group": "Manual" }, "1.4.3": { "group": "Manual" }, - "1.4.4": { "responsibility": "Component", "group": "Manual", "flagged": true }, + "1.4.4": { "responsibility": "Component" }, "1.4.5": { "responsibility": "Shared" }, "1.4.10": { "responsibility": "Component" }, "1.4.11": { "responsibility": "Shared", "group": "Manual" }, diff --git a/packages/mui-material/src/Avatar/accessibility.md b/packages/mui-material/src/Avatar/accessibility.md index 25a72d1ebdaa93..1dcbca6429f578 100644 --- a/packages/mui-material/src/Avatar/accessibility.md +++ b/packages/mui-material/src/Avatar/accessibility.md @@ -10,7 +10,7 @@ Rated against WCAG 2.2 Level A and AA. See the [reports legend](../accessibility | ⚠️ Partially Supports | 2 | | ❌ Does Not Support | 0 | | ➖ Not Applicable | 44 | -| 🚩 Flagged | 5/11 | +| 🚩 Flagged | 4/11 | ## Known gaps @@ -126,23 +126,6 @@ Tested by: axe-core `color-contrast` ❌ **Pass:** all letter and fallback text meets `4.5:1` (or `3:1` if it's sized to qualify as large text). The default gray letter avatar, the `deepOrange[500]` example, and arbitrary `stringToColor` backgrounds do not meet this without author color overrides. -#### 1.4.4 Resize Text · AA - -`🚩` · `✅ Supports` · `● Component` - - - -- The container is a fixed 40px square with text in rem (`pxToRem(20)`) and `overflow: hidden`. Under full-page browser zoom (the default scaling mechanism), the box and the text scale together, so initials stay fully visible. - -**Manual testing steps** - -1. In a UI with letter avatars, set browser zoom to 200% (Ctrl or Cmd and +) and confirm the box and initials scale together with nothing clipped. -2. Optional: compare against text-only resize (Firefox "Zoom Text Only") to see the px box not scaling; long initials there are an author concern. - - - -**Pass:** initials and fallback text stay fully visible at 200% page zoom. The container scales with the page. - #### 1.4.5 Images of Text · AA `✅ Supports` · `◐ Shared` @@ -209,6 +192,22 @@ Tested by: unit `Avatar.test.js` ### ⚙️ Automated +#### 1.4.4 Resize Text · AA + +`✅ Supports` · `● Component` + +Tested by: Playwright + + + +- The container is a fixed 40px square with text in rem (`pxToRem(20)`) and `overflow: hidden`. Under 200% page zoom, the box and the text scale together, so initials stay fully visible. A Playwright test confirms this on the letter avatars demo. Page zoom decides the 1.4.4 rating (WCAG technique G142). +- The page zoom check and the 1.4.10 reflow check cover 1.4.4 together. The page zoom viewport (500 × 350 px) is wider than the 320 px reflow viewport. So the page zoom check adds the clipping check, and the reflow check covers the narrow width. +- Under text-only resize (for example Firefox "Zoom Text Only"), the text grows but the px box does not. Initials longer than two letters can then be clipped. The layout suite does not run the text-only check for Avatar. + + + +**Pass:** initials and fallback text stay fully visible at 200% page zoom. The container scales with the page. + #### 1.4.10 Reflow · AA `✅ Supports` · `● Component` diff --git a/packages/mui-material/src/Fab/Fab.test.js b/packages/mui-material/src/Fab/Fab.test.js index d1ff7dd41f8372..1851e061d4f23a 100644 --- a/packages/mui-material/src/Fab/Fab.test.js +++ b/packages/mui-material/src/Fab/Fab.test.js @@ -10,9 +10,12 @@ import { import Fab, { fabClasses as classes } from '@mui/material/Fab'; import ButtonBase, { touchRippleClasses } from '@mui/material/ButtonBase'; import Icon from '@mui/material/Icon'; +import SvgIcon from '@mui/material/SvgIcon'; import { ThemeProvider, createTheme } from '@mui/material/styles'; import describeConformance from '../../test/describeConformance'; import * as ripple from '../../test/ripple'; +import { contrastRatio, requiredRatio, WCAG_NON_TEXT_RATIO } from '../../test/contrast'; +import { FAILING_PALETTE_COLORS, PALETTE_CONTRAST_COLORS } from '../../test/contrastContract'; describe('', () => { const { render, renderToString } = createRenderer(); @@ -249,4 +252,253 @@ describe('', () => { expect(effectiveBoxShadow(fab)).to.contain('rgb(255, 0, 0)'); }); }); + + describe('WCAG 2.2 conformance', () => { + const icon = ( + + + + ); + + /** + * Renders one Fab for each palette color. Returns the computed style of each Fab + * and the exact ratio of its foreground against its fill. + */ + function renderPaletteFabs(props, children) { + render( + + {PALETTE_CONTRAST_COLORS.map((color) => ( + + {children ?? color} + + ))} + , + ); + return PALETTE_CONTRAST_COLORS.map((color) => { + const style = window.getComputedStyle(screen.getByRole('button', { name: color })); + return { color, style, ratio: contrastRatio(style.color, style.backgroundColor) }; + }); + } + + it('1.1.1 Non-text Content: names an icon-only Fab from its aria-label', () => { + render({icon}); + + expect(screen.getByRole('button')).toHaveAccessibleName('Add'); + }); + + it('1.4.3 Contrast (Minimum): only the documented palette colors fall short of the required ratio', () => { + // `requiredRatio` picks 4.5:1 or 3:1 from the rendered font size and weight. + const failing = renderPaletteFabs({ variant: 'extended' }) + .filter(({ ratio, style }) => ratio < requiredRatio(style)) + .map(({ color }) => color); + + // The extended label is `contrastText` on `main`, like a contained Button. The + // contract lists colors that fail in either direction; both agree while + // `contrastText` and `background.paper` are both white. + expect(failing).to.deep.equal([...FAILING_PALETTE_COLORS]); + }); + + // jsdom does not resolve `currentColor` in the computed `fill` of the svg. + it.skipIf(isJsdom())( + '1.4.11 Non-text Contrast: the icon reaches 3:1 against the fill in each palette color at rest', + () => { + renderPaletteFabs({}, icon); + + // Measure the painted svg, so an icon that stops using `currentColor` fails. + screen.getAllByTestId('icon').forEach((svg) => { + const fab = svg.closest('button'); + const { fill } = window.getComputedStyle(svg); + const { backgroundColor } = window.getComputedStyle(fab); + expect(contrastRatio(fill, backgroundColor)).to.be.at.least( + WCAG_NON_TEXT_RATIO, + fab.getAttribute('aria-label'), + ); + }); + }, + ); + + it('2.1.1 Keyboard: Enter and Space activate the Fab', async () => { + const handleClick = vi.fn(); + const { user } = render( + + {icon} + , + ); + + await user.tab(); + await user.keyboard('{Enter}'); + expect(handleClick).toHaveBeenCalledTimes(1); + + await user.keyboard(' '); + expect(handleClick).toHaveBeenCalledTimes(2); + }); + + it('2.1.2 No Keyboard Trap: keyboard focus can enter and leave the Fab', async () => { + const { user } = render( + + + {icon} + + , + ); + + await user.tab(); + expect(screen.getByRole('button', { name: 'Before' })).toHaveFocus(); + + await user.tab(); + expect(screen.getByRole('button', { name: 'Middle' })).toHaveFocus(); + + await user.tab(); + expect(screen.getByRole('button', { name: 'After' })).toHaveFocus(); + + await user.tab({ shift: true }); + expect(screen.getByRole('button', { name: 'Middle' })).toHaveFocus(); + + await user.tab({ shift: true }); + expect(screen.getByRole('button', { name: 'Before' })).toHaveFocus(); + }); + + describe('2.4.3 Focus Order', () => { + it('is a single tab stop in natural DOM order with no positive tabIndex', () => { + render({icon}); + + expect(screen.getByRole('button')).to.have.property('tabIndex', 0); + }); + + it('removes a disabled Fab from the tab order', async () => { + const { user } = render( + + + + {icon} + + + , + ); + + await user.tab(); + expect(screen.getByRole('button', { name: 'Before' })).toHaveFocus(); + + await user.tab(); + expect(screen.getByRole('button', { name: 'After' })).toHaveFocus(); + + await user.tab({ shift: true }); + expect(screen.getByRole('button', { name: 'Before' })).toHaveFocus(); + }); + }); + + it('2.5.2 Pointer Cancellation: activates on click, but not when released off the target', async () => { + const handleClick = vi.fn(); + const { user } = render( + + + {icon} + +
+ , + ); + const fab = screen.getByRole('button', { name: 'Add' }); + + // Press on the Fab, move away, then release: nothing runs. + await user.pointer([ + { keys: '[MouseLeft>]', target: fab }, + { target: screen.getByTestId('outside') }, + { keys: '[/MouseLeft]' }, + ]); + expect(handleClick).toHaveBeenCalledTimes(0); + + await user.click(fab); + expect(handleClick).toHaveBeenCalledTimes(1); + }); + + it('2.5.3 Label in Name: an extended Fab takes its name from the visible text', () => { + render( + + {icon} + Navigate + , + ); + + expect(screen.getByRole('button')).toHaveAccessibleName('Navigate'); + }); + + it('3.2.1 On Focus: moving keyboard focus to the Fab does not activate it', async () => { + const handleClick = vi.fn(); + const { user } = render( + + {icon} + , + ); + + await user.tab(); + expect(screen.getByRole('button')).toHaveFocus(); + expect(handleClick).toHaveBeenCalledTimes(0); + }); + + it('3.2.2 On Input: a toggle activated with Enter changes aria-pressed and keeps focus', async () => { + function ToggleFab() { + const [pressed, setPressed] = React.useState(false); + return ( + setPressed((previous) => !previous)} + > + {icon} + + ); + } + const { user } = render(); + const fab = screen.getByRole('button', { name: 'Favorite' }); + + await user.tab(); + expect(fab).to.have.attribute('aria-pressed', 'false'); + + await user.keyboard('{Enter}'); + expect(fab).to.have.attribute('aria-pressed', 'true'); + expect(fab).toHaveFocus(); + + await user.keyboard('{Enter}'); + expect(fab).to.have.attribute('aria-pressed', 'false'); + expect(fab).toHaveFocus(); + }); + + describe('4.1.2 Name, Role, Value', () => { + it('renders a native button with the correct role and name', () => { + render({icon}); + + expect(screen.getByRole('button', { name: 'Add' })).to.have.tagName('button'); + }); + + it('exposes the link role when rendered as an anchor', () => { + render( + + {icon} + , + ); + + expect(screen.getByRole('link', { name: 'Compose' })).to.have.tagName('a'); + }); + + it('reflects the disabled state', () => { + render( + + {icon} + , + ); + + expect(screen.getByRole('button', { name: 'Add' })).to.have.property('disabled', true); + }); + + it('exposes the pressed state of a toggle Fab', () => { + render( + + {icon} + , + ); + + expect(screen.getByRole('button', { name: 'Favorite', pressed: true })).not.to.equal(null); + }); + }); + }); }); diff --git a/packages/mui-material/src/Fab/accessibility.json b/packages/mui-material/src/Fab/accessibility.json new file mode 100644 index 00000000000000..6a2844c1778754 --- /dev/null +++ b/packages/mui-material/src/Fab/accessibility.json @@ -0,0 +1,23 @@ +{ + "axe": "docs/data/material/components/floating-action-button/floating-action-button.a11y.json", + "tests": ["ButtonBase"], + "criteria": { + "1.3.2": { "flagged": true }, + "1.3.3": { "flagged": true }, + "1.4.3": { "responsibility": "Component" }, + "1.4.10": { + "conformance": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid" + }, + "1.4.12": { + "conformance": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid" + }, + "2.4.4": {}, + "2.4.11": { "flagged": true }, + "3.2.4": { "flagged": true } + }, + "notApplicable": ["3.3.2"] +} diff --git a/packages/mui-material/src/Fab/accessibility.md b/packages/mui-material/src/Fab/accessibility.md new file mode 100644 index 00000000000000..fc1ef9a5d13eb5 --- /dev/null +++ b/packages/mui-material/src/Fab/accessibility.md @@ -0,0 +1,536 @@ + + +# Fab accessibility conformance + +Rated against WCAG 2.2 Level A and AA. See the [reports legend](../accessibility.md). + +| Result | Count | +| :-------------------- | :---- | +| ✅ Supports | 21 | +| ⚠️ Partially Supports | 4 | +| ❌ Does Not Support | 0 | +| ➖ Not Applicable | 30 | +| 🚩 Flagged | 6/25 | + +## Known gaps + +- ⚠️ **1.4.3 Contrast (Minimum).** Extended labels in `info` (`3.86:1`) and `warning` (`3.11:1`) are less than `4.5:1`. On keyboard focus, the focus ripple behind the label lowers each palette color to `2.23:1` (`warning`) to `3.57:1` (`secondary`), and `primary` to `2.80:1`. A press lowers them to `4.16:1` or less. Use `disableFocusRipple` with the `focusVisible` theme ring. +- ⚠️ **1.4.10 Reflow.** The extended Fab has a fixed height. At 320 CSS px, a label that wraps onto three lines spills out of every size. Two lines reach the edges of the `small` Fab. +- ⚠️ **1.4.11 Non-text Contrast.** The default focus indicator is the focus ripple, at `1.39:1` to `1.85:1` against the fill. On the ripple, `primary`, `info`, `success`, and `warning` icons are less than `3:1`. The `focusVisible` theme ring does not remove the ripple, so also set `disableFocusRipple`. +- ⚠️ **1.4.12 Text Spacing.** The extended Fab has a fixed height. The WCAG letter and word spacing can make a label wrap onto one more line. Two lines stay inside the Fab. Three lines spill out of every size. + +## Success criteria + +### 🔍 Manual + +#### 1.3.2 Meaningful Sequence · A + +`🚩` · `✅ Supports` · `○ Author` + + + +- The Fab is one control. An extended Fab renders its children in source order, usually the icon and then the label. The icon is `aria-hidden`. +- The author often gives the Fab a fixed position, so it can show far from its place in the DOM. Its place in the reading order is an author decision. + +**Manual testing steps** + +1. On a page with a fixed Fab, press Tab repeatedly. +2. Write down when the Fab gets focus. +3. Compare this with the place where the Fab shows on the page. + + + +**Pass:** the Fab gets focus at a logical point, for example after the main content that it acts on. + +#### 1.3.3 Sensory Characteristics · A + +`🚩` · `✅ Supports` · `○ Author` + + + +- Users identify a Fab by its accessible name, not only by its shape, color, or position. +- Do not refer to the Fab by shape or position alone in instructions. For example, do not write "press the round button at the bottom right". + +**Manual testing steps** + +1. Find product copy that tells users to operate the Fab. +2. Make sure that it names the action, not only the shape, color, or position of the Fab. + + + +**Pass:** each instruction names the action, for example "select Compose". + +#### 1.4.5 Images of Text · AA + +`✅ Supports` · `○ Author` + + + +- The Fab renders an SVG icon, an icon-font glyph, or real text. None of these is an image of text. + +**Manual testing steps** + +1. Inspect each Fab in the product. +2. Make sure that no icon is an image of words. + + + +**Pass:** no Fab shows words as an image. A logo with an accessible name is an exception. + +#### 2.4.11 Focus Not Obscured (Minimum) · AA + +`🚩` · `✅ Supports` · `○ Author` + + + +- The author often sets `position: fixed` on a Fab. The component sets `z-index: theme.zIndex.fab` (1050). So the Fab can hide other focused elements, which is the main risk for this criterion. +- When you press Tab forward, the browser scrolls each element to the bottom edge, which is under the Fab. Set `scroll-padding-bottom` on the scroll container to at least the Fab height plus its offset. +- The Fab itself can also be hidden by a sticky footer or a banner. + +**Manual testing steps** + +1. Put the Fab in a fixed position at the bottom of a long page. +2. Press Tab forward through the content behind the Fab. +3. At each focused element near the Fab, look for the focus indicator. +4. Make the browser window short and do the test again. + + + +**Pass:** the Fab never fully hides a focused element. + +#### 3.2.4 Consistent Identification · AA + +`🚩` · `✅ Supports` · `○ Author` + + + +- The component gives one stable accessible name for each set of props. +- Consistency is a property across pages. The same Fab action must use the same icon and label on each page. + +**Manual testing steps** + +1. List the Fabs that do the same job across the product. +2. Compare their icons and labels. + + + +**Pass:** the same job uses the same icon and label, and no icon is used for different jobs. + +### 🔁 Hybrid + +#### 1.1.1 Non-text Content · A + +`✅ Supports` · `◐ Shared` + +Tested by: unit `Fab.test.js` + + + +- An icon-only Fab has no visible text. Its accessible name comes from `aria-label`, `aria-labelledby`, a `Tooltip` title, or `titleAccess` on the icon. The author must supply it, and the component does not warn when it is missing. +- An extended Fab takes its name from its visible label. +- `SvgIcon` and `Icon` children are `aria-hidden`, unless `SvgIcon` sets `titleAccess`. The author must hide an icon of another type. +- A unit test confirms that `aria-label` names the Fab. The `SvgIcon` tests cover the default `aria-hidden`. axe-core `button-name` confirms that each demo has a name, and `aria-command-name` confirms the non-native fixture. Both rules are listed under 4.1.2. + +**Manual testing steps** + +1. Start a screen reader (NVDA with Chrome, or VoiceOver with Safari). +2. Press Tab to an icon-only Fab and to an extended Fab. +3. Listen to the announcement for each. + + + +**Pass:** the icon-only Fab announces its `aria-label`, the extended Fab announces its visible text, and the icon is silent. + +#### 1.3.1 Info and Relationships · A + +`✅ Supports` · `◐ Shared` + + + +- The component sets the correct role: `button`, `link` with `href`, or `role="button"` for a non-native element. It sets the disabled state. axe-core ARIA rules pass on the demos. +- A toggle Fab, such as "Add to favorites", needs `aria-pressed` from the author. + +**Manual testing steps** + +1. Start a screen reader. +2. Move the screen-reader cursor to a plain Fab, an `href` Fab, a disabled one, and one with `aria-pressed`. +3. Listen to the role and state for each. + +In NVDA, move the cursor with the arrow keys. In VoiceOver, use VO+Right Arrow. + + + +**Pass:** the screen reader announces "button", "link", the disabled state, and the pressed state where they apply. + +#### 1.4.1 Use of Color · A + +`🚩` · `✅ Supports` · `◐ Shared` + + + +- The purpose of a Fab comes from its icon and its label. Focus and disabled do not rely on color alone. +- The `color` prop only changes the fill. If two Fabs differ only by color, the meaning is lost without color. + +**Manual testing steps** + +1. In Chrome DevTools, open the Rendering tab. +2. Select Emulate vision deficiencies > Achromatopsia. +3. Make sure that you can identify the purpose of each Fab. + + + +**Pass:** the purpose of each Fab stays clear without color. + +#### 1.4.3 Contrast (Minimum) · AA + +`⚠️ Partially Supports` · `● Component` + +Tested by: unit `Fab.test.js` · axe-core `color-contrast` ❌ + + + +- An extended Fab renders `contrastText` on `main`, like a contained Button. `info` (`3.86:1`) and `warning` (`3.11:1`) are less than `4.5:1`. A unit test picks the threshold from the rendered font size and weight. It confirms that only these colors fail, from the [palette contrast contract](../../test/contrastContract.ts). axe-core `color-contrast` records the failure. +- On hover, the fill changes to `dark`. Each color then reaches `4.5:1`, except `warning` at `3.79:1`. +- On keyboard focus and on press, the ripple paints `contrastText` at `30%` over the label. Each palette color is then less than `4.5:1`: `2.23:1` (`warning`) to `3.57:1` (`secondary`) on focus, and up to `4.16:1` on a mouse press. This also applies to a contained Button. +- The `focusVisible` theme ring does not remove the focus ripple. To keep the label on the plain fill, set `disableFocusRipple` with the ring. +- The `default` color is `rgba(0, 0, 0, 0.87)` on `grey[300]`, at `12.77:1` (`grey[900]`, `12.20:1`, with CSS theme variables). It stays at `7.43:1` or more on the ripple. +- With `color="inherit"`, the label takes the parent text color on a `grey[300]` fill. The author must check this pair. Disabled Fabs are exempt. + +**Manual testing steps** + +1. With a contrast checker, measure the label against the fill, for each color in use. +2. Hover over each Fab and measure again. +3. Press Tab to each Fab and measure the label on the focus ripple. +4. Measure the icon against `3:1`, see 1.4.11. + + + +**Pass:** the label is at least `4.5:1` in the resting, hover, focused, and pressed states. `info` and `warning` fail at rest, and each palette color fails on the ripple. + +#### 1.4.10 Reflow · AA + +`⚠️ Partially Supports` · `● Component` + +Tested by: Playwright + + + +- A circular Fab has a fixed size of 40 to 56 CSS px. An extended Fab is as wide as its label. A Playwright test confirms that the extended-size demo does not scroll horizontally at 320 px. +- At 320 px, a label wider than the viewport wraps. The fixed height does not grow. +- Two lines at line-height 1.75 have line boxes of 49 px, but the uppercase glyphs are only about 35 px high. They stay inside the `large` (48 px) and `medium` (40 px) Fabs. They reach the edges of the `small` Fab (34 px). +- Three lines of glyphs are about 59 px high. They spill out of every size by 5 to 13 px at the top and at the bottom, as under text-only resize in 1.4.4. + +**Manual testing steps** + +1. Set the viewport width to 320 CSS px. +2. Render an extended Fab with a label that wraps onto three lines. +3. Make sure that the full label stays inside the Fab. + + + +**Pass:** the full label stays inside the Fab. A label that wraps onto three lines fails with the default styles. + +#### 1.4.11 Non-text Contrast · AA + +`🚩` · `⚠️ Partially Supports` · `● Component` + +Tested by: unit `Fab.test.js` + + + +- The icon is `contrastText` on `main`. A browser unit test reads the computed `fill` of the svg. It confirms that the icon reaches `3:1` against the fill at rest, in each of the six palette colors (`primary` to `warning`). `warning` is the lowest, at `3.11:1`. +- The focus indicator is the focus ripple: `contrastText` at `30%` opacity over the fill. It is `1.39:1` (`warning`) to `1.85:1` (`default`) against the fill, which is less than `3:1`. The box-shadow does not change on focus. +- On the ripple, the icon is less than `3:1` in `warning` (`2.23:1`), `info` (`2.54:1`), `primary` (`2.80:1`), and `success` (`2.92:1`). +- The `focusVisible` theme ring does not remove the focus ripple. Set `disableFocusRipple` with the ring, so that the icon stays on the plain fill. +- The `default` fill (`grey[300]`) is `1.32:1` against a white page. The icon or label identifies the Fab, so the fill boundary does not need `3:1`. + +**Manual testing steps** + +1. With a contrast checker, measure the icon against the fill, for each color in use. +2. Press Tab to the Fab so that the focus indicator shows. +3. Sample the rendered ripple color with the DevTools color picker. +4. Measure the ripple against the fill, and the icon against the ripple. +5. Set the `focusVisible` theme ring and `disableFocusRipple`. +6. Measure the ring against the page behind the Fab. + + + +**Pass:** the icon and the focus indicator are at least `3:1`. Disabled Fabs are exempt. The default focus ripple fails. The `focusVisible` theme ring with `disableFocusRipple` fixes it on a light page. On a colored or dark page, measure the ring. + +#### 1.4.12 Text Spacing · AA + +`⚠️ Partially Supports` · `● Component` + +Tested by: Playwright + + + +- A Playwright test applies the WCAG text-spacing values to the extended-size demo. Its short labels do not overflow. +- The label already has line-height 1.75, so the WCAG value of 1.5 does not make it taller. +- The letter and word spacing make the label wider, so a label can wrap onto one more line. The fixed height does not grow. +- With two lines, the line boxes are 42 px high, but the uppercase glyphs are only about 31 px high. The glyphs stay inside every size. In the `small` Fab (34 px), about 1 px stays free at the top and at the bottom. +- With three lines, the glyphs are about 52 px high. They spill out of the `large` (48 px), `medium` (40 px), and `small` Fabs by 2 to 10 px at the top and at the bottom. +- Thus a label that has two lines at the default spacing can fail: with the WCAG values, it wraps onto three lines. +- The second column of the `FabA11yLongLabel` fixture shows the two-line case. Each label fits on one line at the default spacing, and wraps to two lines with the WCAG values. +- The Playwright check measures text boxes, which are taller than the glyphs: 37 px for two lines. Thus it reports the `small` Fab for a label of two lines, although the glyphs stay inside. + +**Manual testing steps** + +1. Render an extended Fab whose label has two lines, in a container a little wider than the label. +2. Apply the WCAG text-spacing values, for example with a text-spacing bookmarklet. +3. Make sure that the full label stays inside the Fab. + + + +**Pass:** the full label stays inside the Fab. A label that wraps onto three lines fails in every size with the default styles. + +#### 2.4.4 Link Purpose (In Context) · A + +`✅ Supports` · `◐ Shared` + +Tested by: axe-core `link-name` ✅ + + + +- This applies only with `href`, where the root is an ``. axe-core `link-name` confirms that the link fixture has a name. + +**Manual testing steps** + +1. Find Fabs that use `href`. +2. Read the name of each, together with the content around it. + + + +**Pass:** a user can tell where each link goes. + +#### 2.4.6 Headings and Labels · AA + +`✅ Supports` · `◐ Shared` + + + +- The accessible name is the label of the control. axe-core `button-name` and `link-name` confirm that it is present. +- Whether the label describes the action is an authoring concern. + +**Manual testing steps** + +1. List the name of each Fab. +2. Read each name without its icon. + + + +**Pass:** each name tells the action, for example "Compose message", not "Add icon". + +#### 2.4.7 Focus Visible · AA + +`✅ Supports` · `◐ Shared` + +Tested by: Playwright + + + +- Keyboard focus shows the focus ripple. A mouse click does not show it. A Playwright test confirms that keyboard focus changes how the Fab looks. +- On focus, the box-shadow stays at `shadows[6]`, the same as at rest. `disableRipple` and `disableFocusRipple` remove the ripple, and then the Fab has no focus indicator. +- With `focusVisible: true` on the theme, keyboard focus adds an outline ring next to the shadow. See [Focus visible](https://mui.com/material-ui/customization/focus-visible/). A Playwright test confirms the ring with the ripple disabled. + +**Manual testing steps** + +1. Press Tab to a Fab. +2. Make sure that a focus indicator shows. +3. Click a Fab with the mouse. +4. Make sure that the focus indicator does not show. +5. Press Tab to a Fab with `disableRipple` and the default theme. +6. Set `focusVisible: true` on the theme, and press Tab to the same Fab. + + + +**Pass:** each Fab shows a visible indicator on keyboard focus. With `disableRipple` and the default theme, no indicator shows, and the author must add one. The `focusVisible` theme ring fixes it. + +#### 4.1.2 Name, Role, Value · A + +`✅ Supports` · `◐ Shared` + +Tested by: unit `Fab.test.js` · axe-core `aria-allowed-attr` ✅, `aria-command-name` ✅, `aria-conditional-attr` ✅, `aria-deprecated-role` ✅, `aria-hidden-focus` ✅, `aria-prohibited-attr` ✅, `aria-required-attr` ✅, `aria-roles` ✅, `aria-valid-attr` ✅, `aria-valid-attr-value` ✅, `button-name` ✅, `link-name` ✅, `nested-interactive` ✅ + + + +- A native ` + + + diff --git a/test/regressions/index.test.js b/test/regressions/index.test.js index 0c99c32300e61c..b8b239833ccf9e 100644 --- a/test/regressions/index.test.js +++ b/test/regressions/index.test.js @@ -603,7 +603,8 @@ async function main() { function registerCssLayoutSuites({ test, renderFixture, routes }) { /** * Reports the document's horizontal overflow after applying `css`, plus any - * element whose own content escapes its box. Both are the failure modes the + * element whose own content escapes its box: `clipped` when the box hides its + * overflow, `spilled` when it does not. These are the failure modes the * reflow, resize-text, and text-spacing criteria care about. */ async function measureOverflow(page, css) { @@ -618,43 +619,79 @@ function registerCssLayoutSuites({ test, renderFixture, routes }) { const root = document.documentElement; const horizontalOverflow = root.scrollWidth - root.clientWidth; - // These criteria are about losing *text*, so only elements that hide - // overflow and actually render text count. Measuring the text range - // rather than scrollWidth avoids flagging boxes that deliberately clip - // decoration — a Switch root clipping its ripple loses no content. - const clipped = Array.from(document.querySelectorAll('[class*="Mui"]')) - .filter((node) => { - const { overflowX, overflowY, visibility, display } = window.getComputedStyle(node); - if (overflowX !== 'hidden' && overflowY !== 'hidden') { - return false; - } - // Deliberately hidden content — a collapsed Accordion panel — is not - // clipped content: these criteria are about what is on screen. - if (visibility === 'hidden' || display === 'none') { - return false; - } - const box = node.getBoundingClientRect(); - if (box.width === 0 || box.height === 0) { - return false; - } - return node.textContent.trim() !== ''; - }) + const escapes = (text, box) => + text.left < box.left - 0.5 || + text.right > box.right + 0.5 || + text.top < box.top - 0.5 || + text.bottom > box.bottom + 0.5; + const hidesOverflow = (node) => { + const { overflowX, overflowY } = window.getComputedStyle(node); + return overflowX === 'hidden' || overflowY === 'hidden'; + }; + + // These criteria are about losing *text*, so only elements that actually + // render text count. + const withText = Array.from(document.querySelectorAll('[class*="Mui"]')).filter((node) => { + const { visibility, display } = window.getComputedStyle(node); + // Deliberately hidden content — a collapsed Accordion panel — is not + // clipped content: these criteria are about what is on screen. + if (visibility === 'hidden' || display === 'none') { + return false; + } + const box = node.getBoundingClientRect(); + if (box.width === 0 || box.height === 0) { + return false; + } + return node.textContent.trim() !== ''; + }); + + // Measuring the text range rather than scrollWidth avoids flagging boxes + // that deliberately clip decoration — a Switch root clipping its ripple + // loses no content. + const clipped = withText + .filter(hidesOverflow) .filter((node) => { const range = document.createRange(); range.selectNodeContents(node); - const text = range.getBoundingClientRect(); + return escapes(range.getBoundingClientRect(), node.getBoundingClientRect()); + }) + .map((node) => node.getAttribute('class')); + + // A box that shows its overflow hides no text, but text that leaves a + // fixed-size box can land on a background that makes it unreadable — a + // wrapped label above and below an extended Fab. Only the text nodes of + // the element itself count: a positioned child, such as a floating label, + // is outside its parent by design. + // + // The range measures line boxes, which are taller than the glyphs. One + // line can thus be taller than a small fixed box while its glyphs stay + // inside, such as the count in a Badge at a 200% text size. So above and + // below the box, only text that wraps counts. To the left and right, any + // text counts. + const spilled = withText + .filter((node) => !hidesOverflow(node)) + .filter((node) => { const box = node.getBoundingClientRect(); - return ( - text.left < box.left - 0.5 || - text.right > box.right + 0.5 || - text.top < box.top - 0.5 || - text.bottom > box.bottom + 0.5 - ); + return Array.from(node.childNodes).some((child) => { + if (child.nodeType !== Node.TEXT_NODE || child.textContent.trim() === '') { + return false; + } + const range = document.createRange(); + range.selectNodeContents(child); + const text = range.getBoundingClientRect(); + if (text.left < box.left - 0.5 || text.right > box.right + 0.5) { + return true; + } + const lineTops = new Set( + Array.from(range.getClientRects(), (line) => Math.round(line.top)), + ); + return lineTops.size > 1 && escapes(text, box); + }); }) .map((node) => node.getAttribute('class')); style.remove(); - return { horizontalOverflow, clipped: clipped.slice(0, 3) }; + return { horizontalOverflow, clipped: clipped.slice(0, 3), spilled: spilled.slice(0, 3) }; }, css); } @@ -662,7 +699,7 @@ function registerCssLayoutSuites({ test, renderFixture, routes }) { '* { line-height: 1.5 !important; letter-spacing: 0.12em !important;' + ' word-spacing: 0.16em !important; } p { margin-bottom: 2em !important; }'; - CSS_LAYOUT_SUITES.forEach(({ component, route, skipCriteria = [] }) => { + CSS_LAYOUT_SUITES.forEach(({ component, route, skipCriteria = [], textOnlyResize = true }) => { // A slug only enters the demo bundle once its component is enrolled, so skip // entries this build doesn't contain rather than waiting for a fixture that // was never bundled. `routes` also leaves out routes below their React floor. @@ -695,12 +732,48 @@ function registerCssLayoutSuites({ test, renderFixture, routes }) { }, ); + // 200% page zoom halves the CSS viewport. It decides the 1.4.4 rating + // (WCAG technique G142). The text-only check below is stricter. + // This viewport is wider than the 1.4.10 one, so this check adds the clipping test. + // The reports state that the two checks cover 1.4.4 together. test.runIf(covers('1.4.4'))( - '1.4.4 Resize Text: content survives a 200% text size', + '1.4.4 Resize Text: content survives 200% page zoom', + async ({ pooled }) => { + const { page } = pooled; + await page.setViewportSize({ + width: DEFAULT_VIEWPORT.width / 2, + height: DEFAULT_VIEWPORT.height / 2, + }); + try { + await renderFixture(page, route); + const { horizontalOverflow, clipped, spilled } = await measureOverflow(page, ''); + if (horizontalOverflow > 1) { + throw new Error( + `${component} overflows horizontally by ${horizontalOverflow}px at 200% page zoom`, + ); + } + if (clipped.length > 0) { + throw new Error( + `${component} clips its own content at 200% page zoom: ${clipped.join(', ')}`, + ); + } + if (spilled.length > 0) { + throw new Error( + `${component} text spills out of its box at 200% page zoom: ${spilled.join(', ')}`, + ); + } + } finally { + await page.setViewportSize(DEFAULT_VIEWPORT); + } + }, + ); + + test.runIf(covers('1.4.4') && textOnlyResize)( + '1.4.4 Resize Text: content survives a 200% text-only resize', async ({ pooled }) => { const { page } = pooled; await renderFixture(page, route); - const { horizontalOverflow, clipped } = await measureOverflow( + const { horizontalOverflow, clipped, spilled } = await measureOverflow( page, 'html { font-size: 200% !important; }', ); @@ -712,6 +785,11 @@ function registerCssLayoutSuites({ test, renderFixture, routes }) { if (clipped.length > 0) { throw new Error(`${component} clips its own content at 200%: ${clipped.join(', ')}`); } + if (spilled.length > 0) { + throw new Error( + `${component} text spills out of its box at 200%: ${spilled.join(', ')}`, + ); + } }, ); @@ -720,7 +798,10 @@ function registerCssLayoutSuites({ test, renderFixture, routes }) { async ({ pooled }) => { const { page } = pooled; await renderFixture(page, route); - const { horizontalOverflow, clipped } = await measureOverflow(page, TEXT_SPACING_CSS); + const { horizontalOverflow, clipped, spilled } = await measureOverflow( + page, + TEXT_SPACING_CSS, + ); if (horizontalOverflow > 1) { throw new Error( `${component} overflows horizontally by ${horizontalOverflow}px under the` + @@ -733,10 +814,32 @@ function registerCssLayoutSuites({ test, renderFixture, routes }) { ` ${clipped.join(', ')}`, ); } + if (spilled.length > 0) { + throw new Error( + `${component} text spills out of its box under the WCAG text-spacing overrides:` + + ` ${spilled.join(', ')}`, + ); + } }, ); }); }); + + // A tripwire for the Fab 1.4.10 and 1.4.12 gap, and the proof that `spilled` + // sees a label that leaves a fixed-height box. The fixture applies the WCAG + // text spacing and the 200% text size itself. When this fails, the extended Fab + // grows with its label: update Fab/accessibility.md and knownGaps.json. + const FAB_LONG_LABEL_ROUTE = '/a11y-floating-action-button/FabA11yLongLabel'; + describe.runIf(routes.includes(FAB_LONG_LABEL_ROUTE))('Fab long label', () => { + test('known gap: a label that wraps spills out of the extended Fab', async ({ pooled }) => { + const { page } = pooled; + await renderFixture(page, FAB_LONG_LABEL_ROUTE); + const { spilled } = await measureOverflow(page, ''); + if (!spilled.some((className) => className.includes('MuiFab-root'))) { + throw new Error('No label spills out of a Fab in FabA11yLongLabel; the gap may be fixed'); + } + }); + }); } /** @@ -784,6 +887,7 @@ function registerFocusVisibleSuites({ test, renderFixture, routes }) { { component: 'Button (text)', route: RING_ROUTE, selector: '.MuiButton-text' }, { component: 'Button (outlined)', route: RING_ROUTE, selector: '.MuiButton-outlined' }, { component: 'Button (contained)', route: RING_ROUTE, selector: '.MuiButton-contained' }, + { component: 'Fab', route: RING_ROUTE, selector: '.MuiFab-root' }, { component: 'Checkbox', route: RING_ROUTE, selector: '.MuiCheckbox-root' }, { component: 'IconButton', route: RING_ROUTE, selector: '.MuiIconButton-root' }, { component: 'Radio', route: RING_ROUTE, selector: '.MuiRadio-root' },