diff --git a/docs/data/material/components/chips/chips.a11y.json b/docs/data/material/components/chips/chips.a11y.json new file mode 100644 index 00000000000000..e401e75a5d8a8b --- /dev/null +++ b/docs/data/material/components/chips/chips.a11y.json @@ -0,0 +1,698 @@ +{ + "AvatarChips": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + } + } + }, + "BasicChips": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + } + } + }, + "ChipA11yColorMatrix": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "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"] + }, + "color-contrast": { + "status": "fail", + "tags": ["wcag2aa"] + } + } + }, + "ChipA11yKnownGaps": { + "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"] + }, + "color-contrast": { + "status": "fail", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "ChipA11yLongLabel": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "ChipA11ySemanticStates": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "link-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "ChipsArray": { + "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"] + }, + "avoid-inline-spacing": { + "status": "pass", + "tags": ["wcag21aa"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "list": { + "status": "pass", + "tags": ["wcag2a"] + }, + "listitem": { + "status": "pass", + "tags": ["wcag2a"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "ClickableAndDeletableChips": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "ClickableChips": { + "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-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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "ClickableLinkChips": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "link-name": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "ColorChips": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + } + } + }, + "CustomDeleteIconChips": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "DeletableChips": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + }, + "nested-interactive": { + "status": "pass", + "tags": ["wcag2a"] + }, + "target-size": { + "status": "pass", + "tags": ["wcag22aa"] + } + } + }, + "IconChips": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + } + } + }, + "MultilineChips": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + } + } + }, + "SizesChips": { + "rules": { + "aria-allowed-attr": { + "status": "pass", + "tags": ["wcag2a"] + }, + "aria-conditional-attr": { + "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"] + }, + "color-contrast": { + "status": "pass", + "tags": ["wcag2aa"] + } + } + } +} diff --git a/docs/data/material/components/chips/chips.md b/docs/data/material/components/chips/chips.md index 0b0f5187173b5a..d4298a286b53be 100644 --- a/docs/data/material/components/chips/chips.md +++ b/docs/data/material/components/chips/chips.md @@ -100,4 +100,6 @@ gain depth while clicked or touched. ## Accessibility -If the Chip is deletable or clickable then it is a button in tab order. When the Chip is focused (for example when tabbing) releasing (`keyup` event) `Backspace` or `Delete` will call the `onDelete` handler while releasing `Escape` will blur the Chip. +If the Chip is deletable or clickable then it is a button in tab order. When the Chip is focused (for example when tabbing) releasing (`keyup` event) `Backspace` or `Delete` calls the `onDelete` handler. +After a deletion, move focus to the next chip or to a nearby control, because the deleted chip leaves the page. +To remove a disabled deletable Chip from the tab order, set `skipFocusWhenDisabled`. diff --git a/docs/data/material/getting-started/accessibility/accessibility.md b/docs/data/material/getting-started/accessibility/accessibility.md index fd5b89db6450df..11cbabd3f7b076 100644 --- a/docs/data/material/getting-started/accessibility/accessibility.md +++ b/docs/data/material/getting-started/accessibility/accessibility.md @@ -35,35 +35,36 @@ Each row counts only the criteria that **apply** to that component; criteria tha -| Component | Level A | Level AA | Rated | ✅ Supports | ⚠️ Partially Supports | Verified | Automated | -| :------------------------------------------------------------------------------------------------------------------------------- | ------: | -------: | ----: | ----------: | --------------------: | -------: | --------: | -| [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 | 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 | -| [ButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ButtonGroup/accessibility.md) | 3 | 6 | 9 | 7 | 2 | 6/9 | 3 | -| [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 | -| [FormGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/FormGroup/accessibility.md) | 5 | 2 | 7 | 7 | 0 | 4/7 | 2 | -| [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 | -| [Link](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Link/accessibility.md) | 13 | 11 | 24 | 22 | 2 | 18/24 | 10 | -| [Radio](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Radio/accessibility.md) | 14 | 11 | 25 | 24 | 1 | 23/25 | 11 | -| [RadioGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/RadioGroup/accessibility.md) | 6 | 1 | 7 | 7 | 0 | 4/7 | 2 | -| [Switch](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Switch/accessibility.md) | 14 | 11 | 25 | 24 | 1 | 23/25 | 11 | -| [TextField](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/TextField/accessibility.md) | 14 | 14 | 28 | 25 | 3 | 24/28 | 12 | -| [ToggleButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButton/accessibility.md) | 13 | 11 | 24 | 21 | 3 | 22/24 | 11 | -| [ToggleButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButtonGroup/accessibility.md) | 2 | 2 | 4 | 3 | 1 | 3/4 | 1 | +| Component | Level A | Level AA | Rated | ✅ Supports | ⚠️ Partially Supports | ❌ Does Not Support | Verified | Automated | +| :------------------------------------------------------------------------------------------------------------------------------- | ------: | -------: | ----: | ----------: | --------------------: | ------------------: | -------: | --------: | +| [Accordion](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Accordion/accessibility.md) | 11 | 8 | 19 | 19 | 0 | 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 | 0 | 21/24 | 11 | +| [Avatar](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Avatar/accessibility.md) | 5 | 6 | 11 | 9 | 2 | 0 | 7/11 | 3 | +| [Button](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Button/accessibility.md) | 16 | 12 | 28 | 23 | 5 | 0 | 19/28 | 10 | +| [ButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ButtonGroup/accessibility.md) | 3 | 6 | 9 | 7 | 2 | 0 | 6/9 | 3 | +| [Checkbox](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Checkbox/accessibility.md) | 14 | 11 | 25 | 24 | 1 | 0 | 22/25 | 11 | +| [Chip](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Chip/accessibility.md) | 13 | 11 | 24 | 16 | 7 | 1 | 15/24 | 5 | +| [CircularProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/CircularProgress/accessibility.md) | 6 | 5 | 11 | 8 | 3 | 0 | 6/11 | 1 | +| [Fab](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Fab/accessibility.md) | 14 | 11 | 25 | 21 | 4 | 0 | 19/25 | 9 | +| [FormGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/FormGroup/accessibility.md) | 5 | 2 | 7 | 7 | 0 | 0 | 4/7 | 2 | +| [FormLabel](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/FormLabel/accessibility.md) | 7 | 6 | 13 | 11 | 2 | 0 | 10/13 | 4 | +| [IconButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/IconButton/accessibility.md) | 15 | 12 | 27 | 22 | 5 | 0 | 18/27 | 9 | +| [LinearProgress](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/LinearProgress/accessibility.md) | 6 | 5 | 11 | 8 | 3 | 0 | 6/11 | 1 | +| [Link](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Link/accessibility.md) | 13 | 11 | 24 | 22 | 2 | 0 | 18/24 | 10 | +| [Radio](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Radio/accessibility.md) | 14 | 11 | 25 | 24 | 1 | 0 | 23/25 | 11 | +| [RadioGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/RadioGroup/accessibility.md) | 6 | 1 | 7 | 7 | 0 | 0 | 4/7 | 2 | +| [Switch](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Switch/accessibility.md) | 14 | 11 | 25 | 24 | 1 | 0 | 23/25 | 11 | +| [TextField](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/TextField/accessibility.md) | 14 | 14 | 28 | 25 | 3 | 0 | 24/28 | 12 | +| [ToggleButton](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButton/accessibility.md) | 13 | 11 | 24 | 21 | 3 | 0 | 22/24 | 11 | +| [ToggleButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButtonGroup/accessibility.md) | 2 | 2 | 4 | 3 | 1 | 0 | 3/4 | 1 | -**No component records a ❌ Does Not Support rating for any Level A or AA criterion.** +**1 criterion records a ❌ Does Not Support rating in at least one component.** -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.** +Rolled up to the library level, where each criterion takes the worst rating any assessed component receives, 32 success criteria are exercised: **20 Supports, 11 Partially Supports, 1 Does Not Support.** @@ -86,22 +87,26 @@ An application built with Material UI is not automatically accessible. Material ## Known gaps -Each ⚠️ rating comes from one of the issues below. Some of them can be fixed through the theme today. +Each ⚠️ and ❌ rating comes from one of the issues below. Some of them can be fixed through the theme today. -| 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)
[ButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ButtonGroup/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 | -| **A horizontal group does not wrap, so a wide group can scroll horizontally at 320 px** | [1.4.10 Reflow](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html) | [ButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ButtonGroup/accessibility.md)
[ToggleButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButtonGroup/accessibility.md) | Set `orientation="vertical"` on small screens | -| **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 | +| 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)
[ButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ButtonGroup/accessibility.md)
[Checkbox](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Checkbox/accessibility.md)
[Chip](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Chip/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)
[Chip](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Chip/accessibility.md) (`info`, `warning`, focused or hovered `outlined`)
[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 | +| **A horizontal group does not wrap, so a wide group can scroll horizontally at 320 px** | [1.4.10 Reflow](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html) | [ButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ButtonGroup/accessibility.md)
[ToggleButtonGroup](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/ToggleButtonGroup/accessibility.md) | Set `orientation="vertical"` on small screens | +| **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 Chip label does not wrap, so a long label ends with an ellipsis and hides text** | [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) | [Chip](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Chip/accessibility.md) | Let the label wrap with `height: 'auto'` and `whiteSpace: 'normal'`, as in the multiline demo | +| **A deletable Chip does not expose its delete action, and a disabled delete-only Chip stays focusable and does not expose its disabled state** | [1.1.1 Non-text Content](https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html)
[4.1.2 Name, Role, Value](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html) | [Chip](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Chip/accessibility.md) (`onDelete`; delete-only ignores Enter, Space) | Describe the delete key with `aria-describedby`, and set `skipFocusWhenDisabled` on disabled chips | +| **Deleting a Chip with the keyboard moves focus to the page body** | [2.4.3 Focus Order](https://www.w3.org/WAI/WCAG22/Understanding/focus-order.html) | [Chip](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Chip/accessibility.md) (`onDelete`) | Move focus to the next chip, or to the input, in the `onDelete` handler | +| **The Chip delete icon is smaller than 24 by 24 CSS px, and its contrast is below 3:1** | [1.4.11 Non-text Contrast](https://www.w3.org/WAI/WCAG22/Understanding/non-text-contrast.html)
[2.5.8 Target Size (Minimum)](https://www.w3.org/WAI/WCAG22/Understanding/target-size-minimum.html) | [Chip](https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Chip/accessibility.md) (16 px `small`, 22 px `medium`) | Enlarge the icon, and give it a darker color, with `sx` on `.MuiChip-deleteIcon` | +| **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 7b05f4e2ac050b..a6e62342bdd86a 100644 --- a/docs/data/material/getting-started/accessibility/knownGaps.json +++ b/docs/data/material/getting-started/accessibility/knownGaps.json @@ -7,6 +7,7 @@ "Button", "ButtonGroup", "Checkbox", + "Chip", { "component": "Fab", "note": "the ring needs `disableFocusRipple`" }, { "component": "IconButton", "note": "the ring needs `disableFocusRipple` too" }, "Radio", @@ -21,6 +22,10 @@ "affected": [ "Avatar", { "component": "Button", "note": "`info`, `warning`; `error` in dark mode" }, + { + "component": "Chip", + "note": "`info`, `warning`, focused or hovered `outlined`" + }, { "component": "CircularProgress", "note": "`warning` with `enableTrackSlot`" }, { "component": "Fab", @@ -51,6 +56,30 @@ "affected": [{ "component": "ToggleButton", "note": "`primary`, `error`, `info`, `success`" }], "workaround": "Add a non-color cue to the selected state, such as an icon" }, + { + "gap": "A Chip label does not wrap, so a long label ends with an ellipsis and hides text", + "criteria": ["1.4.10", "1.4.12"], + "affected": ["Chip"], + "workaround": "Let the label wrap with `height: 'auto'` and `whiteSpace: 'normal'`, as in the multiline demo" + }, + { + "gap": "A deletable Chip does not expose its delete action, and a disabled delete-only Chip stays focusable and does not expose its disabled state", + "criteria": ["1.1.1", "4.1.2"], + "affected": [{ "component": "Chip", "note": "`onDelete`; delete-only ignores Enter, Space" }], + "workaround": "Describe the delete key with `aria-describedby`, and set `skipFocusWhenDisabled` on disabled chips" + }, + { + "gap": "Deleting a Chip with the keyboard moves focus to the page body", + "criteria": ["2.4.3"], + "affected": [{ "component": "Chip", "note": "`onDelete`" }], + "workaround": "Move focus to the next chip, or to the input, in the `onDelete` handler" + }, + { + "gap": "The Chip delete icon is smaller than 24 by 24 CSS px, and its contrast is below 3:1", + "criteria": ["1.4.11", "2.5.8"], + "affected": [{ "component": "Chip", "note": "16 px `small`, 22 px `medium`" }], + "workaround": "Enlarge the icon, and give it a darker color, with `sx` on `.MuiChip-deleteIcon`" + }, { "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"], diff --git a/docs/data/material/getting-started/accessibility/scorecard.json b/docs/data/material/getting-started/accessibility/scorecard.json index 54b76c33624947..5cb978b005ebec 100644 --- a/docs/data/material/getting-started/accessibility/scorecard.json +++ b/docs/data/material/getting-started/accessibility/scorecard.json @@ -1,21 +1,21 @@ { "standard": "WCAG 2.2 Level A and AA", - "componentCount": 18, + "componentCount": 20, "totals": { "rated": 32, - "supports": 23, - "partiallySupports": 9, - "doesNotSupport": 0, - "flagged": 14 + "supports": 20, + "partiallySupports": 11, + "doesNotSupport": 1, + "flagged": 16 }, "criteria": [ { "number": "1.1.1", "name": "Non-text Content", "level": "A", - "conformance": "Supports", - "flagged": false, - "affected": [] + "conformance": "Partially Supports", + "flagged": true, + "affected": ["Chip"] }, { "number": "1.3.1", @@ -66,6 +66,7 @@ "affected": [ "Avatar", "Button", + "Chip", "Fab", "FormLabel", "IconButton", @@ -96,13 +97,13 @@ "level": "AA", "conformance": "Partially Supports", "flagged": false, - "affected": ["ButtonGroup", "Fab", "ToggleButtonGroup"] + "affected": ["ButtonGroup", "Chip", "Fab", "ToggleButtonGroup"] }, { "number": "1.4.11", "name": "Non-text Contrast", "level": "AA", - "conformance": "Partially Supports", + "conformance": "Does Not Support", "flagged": true, "affected": [ "AccordionSummary", @@ -126,7 +127,7 @@ "level": "AA", "conformance": "Partially Supports", "flagged": false, - "affected": ["Fab"] + "affected": ["Chip", "Fab"] }, { "number": "2.1.1", @@ -166,7 +167,7 @@ "level": "A", "conformance": "Partially Supports", "flagged": true, - "affected": ["Button", "IconButton"] + "affected": ["Button", "Chip", "IconButton"] }, { "number": "2.4.4", @@ -220,9 +221,9 @@ "number": "2.5.8", "name": "Target Size (Minimum)", "level": "AA", - "conformance": "Supports", - "flagged": false, - "affected": [] + "conformance": "Partially Supports", + "flagged": true, + "affected": ["Chip"] }, { "number": "3.2.1", @@ -276,9 +277,9 @@ "number": "4.1.2", "name": "Name, Role, Value", "level": "A", - "conformance": "Supports", + "conformance": "Partially Supports", "flagged": false, - "affected": [] + "affected": ["Chip"] }, { "number": "4.1.3", @@ -1571,6 +1572,287 @@ "automated": 11 } }, + { + "component": "Chip", + "counts": { + "supports": 16, + "partiallySupports": 7, + "doesNotSupport": 1, + "notApplicable": 31, + "flagged": 9, + "rated": 24 + }, + "gaps": [ + { + "number": "1.1.1", + "name": "Non-text Content", + "conformance": "Partially Supports" + }, + { + "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": "Does Not Support" + }, + { + "number": "1.4.12", + "name": "Text Spacing", + "conformance": "Partially Supports" + }, + { + "number": "2.4.3", + "name": "Focus Order", + "conformance": "Partially Supports" + }, + { + "number": "2.5.8", + "name": "Target Size (Minimum)", + "conformance": "Partially Supports" + }, + { + "number": "4.1.2", + "name": "Name, Role, Value", + "conformance": "Partially Supports" + } + ], + "criteria": [ + { + "number": "1.1.1", + "name": "Non-text Content", + "level": "A", + "conformance": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid", + "flagged": true + }, + { + "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": "Shared", + "group": "Hybrid", + "flagged": false + }, + { + "number": "1.4.11", + "name": "Non-text Contrast", + "level": "AA", + "conformance": "Does Not Support", + "responsibility": "Component", + "group": "Hybrid", + "flagged": true + }, + { + "number": "1.4.12", + "name": "Text Spacing", + "level": "AA", + "conformance": "Partially Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": false + }, + { + "number": "2.1.1", + "name": "Keyboard", + "level": "A", + "conformance": "Supports", + "responsibility": "Component", + "group": "Hybrid", + "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": "Partially Supports", + "responsibility": "Shared", + "group": "Hybrid", + "flagged": true + }, + { + "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": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid", + "flagged": true + }, + { + "number": "3.2.1", + "name": "On Focus", + "level": "A", + "conformance": "Supports", + "responsibility": "Component", + "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": "Partially Supports", + "responsibility": "Component", + "group": "Hybrid", + "flagged": false + } + ], + "summary": { + "rated": 24, + "levelA": 13, + "levelAA": 11, + "supports": 16, + "partiallySupports": 7, + "doesNotSupport": 1, + "verified": 15, + "automated": 5 + } + }, { "component": "CircularProgress", "counts": { diff --git a/packages/mui-material/src/Chip/Chip.test.js b/packages/mui-material/src/Chip/Chip.test.js index 8bcca29cddea47..88eaa19e53c7db 100644 --- a/packages/mui-material/src/Chip/Chip.test.js +++ b/packages/mui-material/src/Chip/Chip.test.js @@ -17,6 +17,8 @@ import { ThemeProvider, createTheme, hexToRgb } from '@mui/material/styles'; import CheckBox from '../internal/svg-icons/CheckBox'; import defaultTheme from '../styles/defaultTheme'; import describeConformance from '../../test/describeConformance'; +import { blend, contrastRatio, WCAG_MINIMUM_RATIO, WCAG_NON_TEXT_RATIO } from '../../test/contrast'; +import { FAILING_PALETTE_COLORS, PALETTE_CONTRAST_COLORS } from '../../test/contrastContract'; describe('', () => { const { render } = createRenderer(); @@ -508,7 +510,7 @@ describe('', () => { }); }); - describe('reacts to keyboard chip', () => { + describe('2.1.1 Keyboard: reacts to keyboard chip', () => { it('should call onKeyDown when a key is pressed', () => { const handleKeydown = stub().callsFake((event) => event.key); render( {}} onKeyDown={handleKeydown} />); @@ -848,4 +850,204 @@ describe('', () => { fireEvent.keyUp(chip, { key: ' ' }); }).not.throw(); }); + + describe('WCAG 2.2 conformance', () => { + describe('1.1.1 Non-text Content', () => { + it('hides the delete icon from assistive technology', () => { + render( {}} />); + + const button = screen.getByRole('button', { name: 'Design' }); + const deleteIcon = button.querySelector(`.${classes.deleteIcon}`); + expect(deleteIcon).to.have.attribute('aria-hidden', 'true'); + }); + }); + + describe('1.4.3 Contrast (Minimum)', () => { + const theme = createTheme(); + + /** The palette colors whose label falls short of 4.5:1 for a variant. */ + function failingColors(variant, background) { + render( + + {PALETTE_CONTRAST_COLORS.map((color) => ( + + ))} + , + ); + return PALETTE_CONTRAST_COLORS.filter((color) => { + const chip = screen.getByText(color).parentElement; + const { color: textColor, backgroundColor } = window.getComputedStyle(chip); + const fill = backgroundColor === 'rgba(0, 0, 0, 0)' ? background : backgroundColor; + return contrastRatio(textColor, fill) < WCAG_MINIMUM_RATIO.normalText; + }); + } + + it('filled labels fall short of 4.5:1 only in the documented palette colors', () => { + expect(failingColors('filled', theme.palette.background.paper)).to.deep.equal([ + ...FAILING_PALETTE_COLORS, + ]); + }); + + it('outlined labels fall short of 4.5:1 only in the documented palette colors', () => { + expect(failingColors('outlined', theme.palette.background.paper)).to.deep.equal([ + ...FAILING_PALETTE_COLORS, + ]); + }); + + it('focused outlined labels fall short of 4.5:1 in every palette color except secondary', () => { + render( + + {PALETTE_CONTRAST_COLORS.map((color) => ( + {}} + className={classes.focusVisible} + /> + ))} + , + ); + const failing = PALETTE_CONTRAST_COLORS.filter((color) => { + const chip = screen.getByRole('button', { name: color }); + const { color: textColor, backgroundColor } = window.getComputedStyle(chip); + // The focus tint is `main` at `focusOpacity`, so composite it over the paper. + const fill = blend(backgroundColor, 1, theme.palette.background.paper); + return contrastRatio(textColor, fill) < WCAG_MINIMUM_RATIO.normalText; + }); + // When this changes, update Chip/accessibility.md and knownGaps.json. + expect(failing).to.deep.equal(['primary', 'error', 'info', 'success', 'warning']); + }); + }); + + it('1.4.11 Non-text Contrast: the default delete icon falls short of 3:1 (documented gap)', () => { + render( {}} />); + + const chip = screen.getByRole('button', { name: 'Design' }); + const deleteIcon = chip.querySelector(`.${classes.deleteIcon}`); + // The default fill is translucent, so composite it over the paper background. + const fill = blend( + window.getComputedStyle(chip).backgroundColor, + 1, + createTheme().palette.background.paper, + ); + const ratio = contrastRatio(window.getComputedStyle(deleteIcon).color, fill); + // When this fails, the icon reaches 3:1: update Chip/accessibility.md and knownGaps.json. + expect(ratio).to.be.below(WCAG_NON_TEXT_RATIO); + }); + + it('2.1.2 No Keyboard Trap: keyboard focus can enter and leave the chip', async () => { + const { user } = render( + + + {}} onDelete={() => {}} /> + + , + ); + + await user.tab(); + 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 }); + await user.tab({ shift: true }); + expect(screen.getByRole('button', { name: 'Before' })).toHaveFocus(); + }); + + describe('2.4.3 Focus Order', () => { + it('makes clickable and deletable chips tab stops in DOM order', async () => { + const { user } = render( + + {}} /> + {}} /> + , + ); + + await user.tab(); + expect(screen.getByRole('button', { name: 'Clickable' })).toHaveFocus(); + await user.tab(); + expect(screen.getByRole('button', { name: 'Deletable' })).toHaveFocus(); + }); + + it('removes a disabled clickable chip from the tab order', async () => { + const { user } = render( + + {}} disabled /> + + , + ); + + await user.tab(); + expect(screen.getByRole('button', { name: 'After' })).toHaveFocus(); + }); + }); + + it('2.5.2 Pointer Cancellation: activates on click, but not when released off the target', async () => { + const handleClick = spy(); + const { user } = render( + + +
+ , + ); + const chip = screen.getByRole('button', { name: 'Filter' }); + + await user.pointer([ + { keys: '[MouseLeft>]', target: chip }, + { target: screen.getByTestId('outside') }, + { keys: '[/MouseLeft]' }, + ]); + expect(handleClick.callCount).to.equal(0); + + await user.click(chip); + expect(handleClick.callCount).to.equal(1); + }); + + it('2.5.3 Label in Name: the accessible name is the visible label', () => { + render( {}} />); + + expect(screen.getByRole('button')).toHaveAccessibleName('Design'); + }); + + it('3.2.1 On Focus: moving keyboard focus to the chip does not activate or delete it', async () => { + const handleClick = spy(); + const handleDelete = spy(); + const { user } = render( + , + ); + + await user.tab(); + expect(screen.getByRole('button')).toHaveFocus(); + expect(handleClick.callCount).to.equal(0); + expect(handleDelete.callCount).to.equal(0); + }); + + describe('4.1.2 Name, Role, Value', () => { + it('gives a static chip no interactive role', () => { + render(); + + expect(screen.queryByRole('button')).to.equal(null); + }); + + it('does not expose the disabled state of a disabled delete-only chip (documented gap)', async () => { + const { user } = render( {}} disabled />); + const chip = screen.getByRole('button'); + + // When this fails, the gap is fixed: update Chip/accessibility.md and knownGaps.json. + expect(chip).not.to.have.attribute('aria-disabled'); + await user.tab(); + expect(chip).toHaveFocus(); + }); + + it('exposes the disabled state of a disabled clickable chip', () => { + render( {}} disabled />); + + expect(screen.getByRole('button')).to.have.attribute('aria-disabled', 'true'); + }); + }); + }); }); diff --git a/packages/mui-material/src/Chip/accessibility.json b/packages/mui-material/src/Chip/accessibility.json new file mode 100644 index 00000000000000..93fbd2df139c5b --- /dev/null +++ b/packages/mui-material/src/Chip/accessibility.json @@ -0,0 +1,56 @@ +{ + "axe": "docs/data/material/components/chips/chips.a11y.json", + "tests": ["ButtonBase"], + "criteria": { + "1.1.1": { + "conformance": "Partially Supports", + "responsibility": "Component", + "flagged": true + }, + "1.3.2": { + "flagged": true + }, + "1.3.3": { + "flagged": true + }, + "1.4.3": { + "responsibility": "Component" + }, + "1.4.11": { + "conformance": "Does Not Support" + }, + "1.4.10": { + "conformance": "Partially Supports", + "group": "Hybrid" + }, + "1.4.12": { + "conformance": "Partially Supports", + "group": "Hybrid" + }, + "2.1.1": { + "group": "Hybrid" + }, + "2.4.3": { + "conformance": "Partially Supports", + "group": "Hybrid", + "flagged": true + }, + "2.4.4": {}, + "2.4.11": { + "flagged": true + }, + "2.5.8": { + "conformance": "Partially Supports", + "group": "Hybrid", + "flagged": true + }, + "3.2.4": { + "flagged": true + }, + "4.1.2": { + "conformance": "Partially Supports", + "responsibility": "Component" + } + }, + "notApplicable": ["3.2.2", "3.3.2"] +} diff --git a/packages/mui-material/src/Chip/accessibility.md b/packages/mui-material/src/Chip/accessibility.md new file mode 100644 index 00000000000000..678ed53c9d31f2 --- /dev/null +++ b/packages/mui-material/src/Chip/accessibility.md @@ -0,0 +1,535 @@ + + +# Chip accessibility conformance + +Rated against WCAG 2.2 Level A and AA. See the [reports legend](../accessibility.md). + +| Result | Count | +| :-------------------- | :---- | +| ✅ Supports | 16 | +| ⚠️ Partially Supports | 7 | +| ❌ Does Not Support | 1 | +| ➖ Not Applicable | 31 | +| 🚩 Flagged | 9/24 | + +## Known gaps + +- ⚠️ **1.1.1 Non-text Content.** The delete icon tells sighted users that the chip can be deleted. No text gives this information to a screen-reader user. +- ⚠️ **1.4.3 Contrast (Minimum).** `info` and `warning` labels are less than `4.5:1` in the `filled` and `outlined` variants. On a focused `outlined` chip, all colors except `secondary` are less than `4.5:1`. On a hovered clickable `outlined` chip, `primary` is also less than `4.5:1`. +- ⚠️ **1.4.10 Reflow.** The label does not wrap. At 320 CSS px, a label that fits a wide layout ends with an ellipsis. +- ❌ **1.4.11 Non-text Contrast.** The default delete icon is `1.86:1` on a `filled` chip and `1.88:1` on an `outlined` chip. The focused background is `1.61:1` against the page. +- ⚠️ **1.4.12 Text Spacing.** The label does not wrap. With the WCAG text-spacing values, a label that fits at default spacing can end with an ellipsis. +- ⚠️ **2.4.3 Focus Order.** The component does not move focus after a deletion. In the ChipsArray demo, a keyboard deletion moves focus to the page body. +- ⚠️ **2.5.8 Target Size (Minimum).** The delete icon is 22 px on a `medium` chip. It is 16 px on a `small` chip. On a clickable and deletable chip, the chip itself is a target, so the spacing exception does not apply. +- ⚠️ **4.1.2 Name, Role, Value.** The component does not set `aria-disabled` on a disabled delete-only chip, and the chip stays focusable. A delete-only chip has the button role, but Enter and Space do nothing. + +## Success criteria + +### 🔍 Manual + +#### 1.3.2 Meaningful Sequence · A + +`🚩` · `✅ Supports` · `○ Author` + + + +- A chip renders its avatar or icon, its label, and its delete icon in DOM order. + +**Manual testing steps** + +1. Press Tab through a set of chips. +2. Compare the focus order with the visual order. + + + +**Pass:** the focus order matches the visual order. + +#### 1.3.3 Sensory Characteristics · A + +`🚩` · `✅ Supports` · `○ Author` + + + +- A chip has a visible label, so users identify it by its text. + +**Manual testing steps** + +1. Find product copy that refers to a chip. +2. Make sure that it names the chip label, not only its color or position. + + + +**Pass:** no instruction refers to a chip by color or position alone. + +#### 1.4.5 Images of Text · AA + +`✅ Supports` · `○ Author` + + + +- The label is real text. + +**Manual testing steps** + +1. Select the text of a chip label with the mouse. + + + +**Pass:** the label is real text. + +#### 2.4.11 Focus Not Obscured (Minimum) · AA + +`🚩` · `✅ Supports` · `○ Author` + + + +- A chip is an ordinary focusable element and does not put itself behind other content. + +**Manual testing steps** + +1. In a page with a sticky header, press Tab to a chip near it. +2. Scroll so that the chip is under the header. +3. Press Shift+Tab. +4. Press Tab to move focus back to the chip. + + + +**Pass:** a part of the focused chip stays visible. + +#### 3.2.4 Consistent Identification · AA + +`🚩` · `✅ Supports` · `○ Author` + + + +- The name comes from the label. Consistency across pages is an authoring concern. + +**Manual testing steps** + +1. List the chips that do the same job across the product. +2. Compare their labels and icons. + + + +**Pass:** the same job uses the same label and icon. + +### 🔁 Hybrid + +#### 1.1.1 Non-text Content · A + +`🚩` · `⚠️ Partially Supports` · `● Component` + +Tested by: unit `Chip.test.js` + + + +- The default delete icon is an `SvgIcon` with `aria-hidden="true"`, and it is not focusable. A unit test confirms `aria-hidden`. A pointer user clicks it. A keyboard user presses Backspace or Delete on the focused chip. +- The icon tells sighted users that the chip can be deleted. No text gives this information to a screen-reader user. +- A custom `deleteIcon` keeps its own attributes. Use an `SvgIcon`, or set `aria-hidden` on it. +- An `icon` is hidden. An `avatar` is not hidden, so its letter or its image `alt` becomes part of the name. Set `alt=""` on an image avatar when the label already gives the name. + +**Manual testing steps** + +1. Start a screen reader (NVDA with Chrome, or VoiceOver with Safari). +2. Press Tab to a deletable chip. +3. Listen to the announcement. +4. Write down how a screen-reader user learns that the chip can be deleted. + + + +**Pass:** the screen reader tells the user that the chip can be deleted. Expected result from the source: it does not. To fix it, add a description with `aria-describedby`. + +#### 1.3.1 Info and Relationships · A + +`✅ Supports` · `◐ Shared` + +Tested by: axe-core `list` ✅, `listitem` ✅ + + + +- A static chip is a `
` with no role. A clickable or deletable chip has the button role. A chip with `component="a"` and `href` is a link. Unit tests confirm the roles. +- A set of chips is not marked as a list. If the chips form a list, the author wraps them in `
    ` and `
  • `, as the ChipsArray demo does. + +**Manual testing steps** + +1. With a screen reader, move to a static, a clickable, and a link chip. +2. Listen to the role of each. +3. Move to a set of chips and listen for a list. + + + +**Pass:** each chip announces the correct role, and a list of chips is announced as a list. + +#### 1.4.1 Use of Color · A + +`🚩` · `✅ Supports` · `◐ Shared` + + + +- The label and the icon give the meaning of a chip. The `color` prop only tints it. +- A selected filter chip that differs only by color loses its meaning without color. This is an authoring concern. + +**Manual testing steps** + +1. Set the view to grayscale. In Chrome DevTools, open the Rendering tab, then select Emulate vision deficiencies > Achromatopsia. +2. Make sure that you can identify each chip and its state. + + + +**Pass:** the meaning and the state of each chip stay clear without color. + +#### 1.4.3 Contrast (Minimum) · AA + +`⚠️ Partially Supports` · `● Component` + +Tested by: unit `Chip.test.js` · axe-core `color-contrast` ❌ + + + +- A `filled` chip renders `contrastText` on `main`. An `outlined` chip renders `main` on the page. In both variants, `info` (`3.86:1`) and `warning` (`3.11:1`) are less than `4.5:1`. +- Unit tests compare the results with the [palette contrast contract](../../test/contrastContract.ts). Only these colors fail. axe-core `color-contrast` fails on the color fixture. +- The `default` color is `text.primary` on `action.selected`, about `13.9:1`. +- On a focused `outlined` chip, the background is `main` at `focusOpacity` (`0.12`) on the page, and the label stays `main`. Only `secondary` stays at `4.5:1` or more: `primary` `3.93:1`, `secondary` `5.21:1`, `error` `4.15:1`, `info` `3.33:1`, `success` `4.37:1`, `warning` `2.73:1`. A unit test confirms this set. +- On a hovered clickable `outlined` chip, the background is `main` at `hoverOpacity` (`0.04`). `primary` (`4.37:1`), `info` (`3.67:1`), and `warning` (`2.98:1`) are less than `4.5:1`. `secondary` is `5.92:1`, `error` is `4.69:1`, and `success` is `4.87:1`. +- A disabled chip is an inactive component, so it is exempt. This includes a disabled delete-only chip, because Backspace and Delete do nothing on it. axe-core still fails its faded label (`2.14:1`), because the chip has no `aria-disabled`. See 4.1.2. +- All values are for the light palette. + +**Manual testing steps** + +1. With a contrast checker, measure the label against the chip background, for each color and variant in use. +2. Press Tab to an `outlined` deletable chip, and measure the label against the focused background. +3. Move the pointer over an `outlined` clickable chip, and measure the label against the hovered background. + + + +**Pass:** each label is at least `4.5:1` at rest, on hover, and on focus. `info` and `warning` fail. On an `outlined` chip, all focused labels except `secondary` fail, and the hovered `primary` label fails. + +#### 1.4.10 Reflow · AA + +`⚠️ Partially Supports` · `◐ Shared` + +Tested by: Playwright + + + +- A chip is `inline-flex` with `maxWidth: 100%`, and its label does not wrap. At 320 CSS px, a label that fits a wide layout ends with an ellipsis. In the `ChipA11yLongLabel` fixture, 283 px of a 353 px label is visible. A Playwright test confirms this gap. +- A Playwright test confirms that the ChipsArray demo, which wraps its chips, does not scroll at 320 px. In a Playwright run, the ClickableAndDeletableChips demo, a row that does not wrap, scrolled by 6 px. This is a layout concern. + +**Manual testing steps** + +1. Render a chip with a long label at full width. +2. Set the viewport width to 320 CSS px. +3. Make sure that the full label stays visible. + + + +**Pass:** the full label stays visible. A long label fails with the default styles. + +#### 1.4.11 Non-text Contrast · AA + +`🚩` · `❌ Does Not Support` · `● Component` + +Tested by: unit `Chip.test.js` + + + +- The delete icon is the only visual sign of the delete control. It is less than `3:1` in 8 of the 14 color and variant combinations, in the light palette: + - `default` `filled`: `text.primary` at `26%` on `action.selected`, `1.86:1`. + - `default` `outlined`: `1.88:1` against white. + - Palette `filled`: `contrastText` at `70%` on `main`, `2.22:1` (`warning`) to `3.83:1` (`secondary`). + - Palette `outlined`: `main` at `70%`, `2.23:1` to `3.57:1`. +- A unit test confirms that the default delete icon is less than `3:1`. +- On keyboard focus, the chip background gets darker. The focused `default` fill is `1.61:1` against the page. On an `outlined` chip, the focus tint against the page is `1.32:1` for `default`, and about `1.14:1` to `1.21:1` for the palette colors. +- The rating is Does Not Support, because most of the functionality fails: the delete icon fails in 8 of the 14 combinations, including both `default` ones, and the default focus indicator fails. +- The `outlined` border is `grey[400]` (`1.88:1` against white), or `main` at `70%` (`2.23:1` to `3.57:1`). The label identifies the chip, so the border does not need `3:1`. +- With `focusVisible: true` on the theme, keyboard focus draws the theme outline ring instead. A Playwright test confirms the ring. + +**Manual testing steps** + +1. With a contrast checker, measure the delete icon against the chip background. +2. Press Tab to a clickable chip. +3. Measure the focused background against the page. +4. Measure the `outlined` border against the page. + + + +**Pass:** the delete icon and the focus indicator are at least `3:1`. The `outlined` border does not need `3:1`, because the label identifies the chip. It is `1.88:1` (default) and `2.23:1` to `3.57:1` (palette). The default delete icon and focus indicator fail. + +#### 1.4.12 Text Spacing · AA + +`⚠️ Partially Supports` · `◐ Shared` + +Tested by: Playwright · axe-core `avoid-inline-spacing` ✅ + + + +- A Playwright test applies the WCAG text-spacing values to the ChipsArray demo. Its short labels stay visible. +- The spacing values make a label about 25% wider. In the `ChipA11yLongLabel` fixture, a label that fits at default spacing (177 px) needs 224 px, and the chip shows 219 px. A Playwright test confirms this gap. + +**Manual testing steps** + +1. Render a chip with a label that just fits its container. +2. Apply the WCAG text-spacing values, for example with a text-spacing bookmarklet. +3. Make sure that the full label stays visible. + + + +**Pass:** the full label stays visible. A long label fails with the default styles. + +#### 2.1.1 Keyboard · A + +`✅ Supports` · `● Component` + +Tested by: unit `Chip.test.js`, `ButtonBase.test.js` + + + +- A clickable chip activates with Enter and Space. A deletable chip calls `onDelete` on the release of Backspace or Delete. Unit tests confirm both. The author's `onDelete` removes the chip. + +**Manual testing steps** + +1. Press Tab to a deletable chip in the ChipsArray demo. +2. Press Backspace or Delete. +3. Press Tab to a clickable chip. +4. Press Enter, then Space. + + + +**Pass:** the deletable chip is removed, and the clickable chip activates on each key. + +#### 2.4.3 Focus Order · A + +`🚩` · `⚠️ Partially Supports` · `◐ Shared` + +Tested by: unit `Chip.test.js` + + + +- A static chip is not a tab stop. A clickable or deletable chip is one tab stop in DOM order, and a disabled clickable chip leaves the tab order. Unit tests confirm this. +- When a chip is deleted, the author's `onDelete` handler removes it. The component does not move focus. In the ChipsArray demo, a keyboard deletion moves focus to the page body. The author must move focus, for example to the next chip. + +**Manual testing steps** + +1. In the ChipsArray demo, press Tab to a chip. +2. Press Backspace to delete it. +3. Write down which element has focus. + + + +**Pass:** focus moves to a nearby chip or control, not to the top of the page. The ChipsArray demo fails. + +#### 2.4.4 Link Purpose (In Context) · A + +`✅ Supports` · `◐ Shared` + +Tested by: axe-core `link-name` ✅ + + + +- This applies to a chip with `component="a"` and `href`. The label must tell the destination. + +**Manual testing steps** + +1. Find chips that link to another page. +2. Read the label of each, together with the content around it. + + + +**Pass:** the destination of each link chip is clear. + +#### 2.4.6 Headings and Labels · AA + +`✅ Supports` · `◐ Shared` + + + +- The label of a chip is its accessible name. Whether it describes the chip is an authoring concern. + +**Manual testing steps** + +1. Read each chip label out of context. + + + +**Pass:** each label describes the item or the filter. + +#### 2.4.7 Focus Visible · AA + +`✅ Supports` · `◐ Shared` + +Tested by: Playwright + + + +- On keyboard focus, a clickable or deletable chip gets a darker background. A Playwright test confirms that keyboard focus changes how a clickable chip looks. +- The change can be hard to see. For a `filled` `error` chip, the background changes from `#d32f2f` to `#c62828`. See 1.4.11. +- With `focusVisible: true` on the theme, keyboard focus draws the theme outline ring. + +**Manual testing steps** + +1. Press Tab to a clickable chip and to a deletable chip. +2. Make sure that a focus indicator shows on each, for each color in use. + + + +**Pass:** each focused chip shows a visible change. + +#### 2.5.8 Target Size (Minimum) · AA + +`🚩` · `⚠️ Partially Supports` · `● Component` + +Tested by: axe-core `target-size` ✅ + + + +- A `medium` chip is 32 px high, and a `small` chip is 24 px high. axe-core `target-size` confirms the chips on the demos. +- The delete icon is a separate pointer target. It is 22 by 22 px on a `medium` chip, and 16 by 16 px on a `small` chip. axe-core does not check the icon, because it is not focusable. +- On a clickable and deletable chip, the chip itself is a target. A 24 px circle on the icon touches it, so the spacing exception does not apply. The equivalent exception does not apply either, because Backspace is not a pointer target. +- On a delete-only chip, the chip does nothing on click, so the spacing exception can apply. + +**Manual testing steps** + +1. In browser DevTools, select the delete icon of a `size="small"` chip. +2. Read the width and height of its box. + + + +**Pass:** the delete icon is at least 24 by 24 CSS px. Or, a 24 px circle on its center touches no other target. The default icon is 22 by 22 px on a `medium` chip, and 16 by 16 px on a `small` chip. + +#### 4.1.2 Name, Role, Value · A + +`⚠️ Partially Supports` · `● Component` + +Tested by: unit `Chip.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` ✅, `link-name` ✅, `nested-interactive` ✅ + + + +- A clickable chip has the button role, and its label is the name. A disabled clickable chip has `aria-disabled="true"`. Unit tests confirm this. +- The component does not set `aria-disabled` on a disabled delete-only chip, and the chip stays focusable. Backspace and Delete do nothing on it. A unit test confirms this gap. +- `skipFocusWhenDisabled` removes a disabled chip from the tab order. The state is still not exposed. +- A delete-only chip has the button role, but Enter and Space do nothing. + +**Manual testing steps** + +1. Start a screen reader. +2. Press Tab past a static chip. Make sure that focus does not stop on it. +3. Press Tab to a clickable chip, a deletable chip, and a disabled deletable chip. +4. Listen to the name, role, and state of each. + + + +**Pass:** each chip announces its label and "button". The disabled chip announces "disabled". The disabled delete-only chip fails. + +### ⚙️ Automated + +#### 1.4.4 Resize Text · AA + +`✅ Supports` · `◐ Shared` + +Tested by: Playwright + + + +- Under 200% page zoom, the chip, its container, and the label scale together, so a label that fits at 100% still fits. A Playwright test confirms this on the ChipsArray 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. +- Another Playwright test confirms that the ChipsArray demo, with short labels, survives a 200% text-only resize. +- Under text-only resize, the label grows but a px-wide container does not. The label does not wrap, so it ends with an ellipsis. In the `ChipA11yLongLabel` fixture, a label fits its 240 px container at 100% (177 px). At a 200% text size, 219 px of the 331 px label is visible. A Playwright test confirms this. +- To make long labels safe under text-only resize, let the label wrap with `height: 'auto'` on the chip, and `display: 'block'` and `whiteSpace: 'normal'` on the label, as the MultilineChips demo does. + + + +**Pass:** the full label stays visible at 200% page zoom. + +#### 2.1.2 No Keyboard Trap · A + +`✅ Supports` · `● Component` + +Tested by: unit `Chip.test.js` + + + +- The chip is one focusable element and does not capture focus. A unit test confirms that Tab and Shift+Tab move focus in and out. + + + +#### 2.5.2 Pointer Cancellation · A + +`✅ Supports` · `● Component` + +Tested by: unit `Chip.test.js` + + + +- Activation runs on `click`, on the pointer up-event. A unit test confirms that a release off the chip cancels the activation. + + + +#### 2.5.3 Label in Name · A + +`✅ Supports` · `◐ Shared` + +Tested by: unit `Chip.test.js` + + + +- The label is the accessible name. A unit test confirms this. + + + +#### 3.2.1 On Focus · A + +`✅ Supports` · `● Component` + +Tested by: unit `Chip.test.js` + + + +- Focus only changes the background. A unit test confirms that focus does not activate or delete the chip. + + + +## Not applicable + +- **1.2.1 Audio-only and Video-only (Prerecorded) (A), 1.2.2 Captions (Prerecorded) (A), 1.2.3 Audio Description or Media Alternative (Prerecorded) (A), 1.2.4 Captions (Live) (AA), 1.2.5 Audio Description (Prerecorded) (AA).** No audio or video. +- **1.3.4 Orientation (AA).** Sets no orientation lock; a layout concern. +- **1.3.5 Identify Input Purpose (AA).** Collects no information about the user through `autocomplete`. +- **1.4.2 Audio Control (A).** Emits no audio. +- **1.4.13 Content on Hover or Focus (AA).** Shows no additional content on hover or focus; a `Tooltip` wrapper would own this. +- **2.1.4 Character Key Shortcuts (A).** Binds no single-character keyboard shortcut. +- **2.2.1 Timing Adjustable (A).** Sets no time limit. +- **2.2.2 Pause, Stop, Hide (A).** No auto-starting moving, blinking, or auto-updating content. +- **2.3.1 Three Flashes or Below Threshold (A).** Nothing flashes. +- **2.4.1 Bypass Blocks (A), 2.4.2 Page Titled (A), 2.4.5 Multiple Ways (AA).** Page or site structure, not a single component. +- **2.5.1 Pointer Gestures (A), 2.5.4 Motion Actuation (A).** Activates on a simple click; reads no device motion. +- **2.5.7 Dragging Movements (AA).** No drag interactions. +- **3.1.1 Language of Page (A), 3.1.2 Language of Parts (AA).** The component emits no `` and no text of its own. A foreign-language label is the author's phrase to mark. +- **3.2.2 On Input (A).** A chip has no setting that the user changes. Deletion is an explicit action. +- **3.2.3 Consistent Navigation (AA).** Covers repeated navigation across a set of pages, not a single component. +- **3.2.6 Consistent Help (A).** Covers consistent placement of help across pages. +- **3.3.1 Error Identification (A), 3.3.3 Error Suggestion (AA), 3.3.4 Error Prevention (Legal, Financial, Data) (AA).** Collects and validates no input; these belong to the form or process. +- **3.3.2 Labels or Instructions (A).** A chip is not a form field. +- **3.3.7 Redundant Entry (A).** Captures no previously entered data to repopulate. +- **3.3.8 Accessible Authentication (Minimum) (AA).** No authentication step; the duty falls on the credential fields. +- **4.1.3 Status Messages (AA).** Emits no status messages; state changes are covered by 4.1.2. + +## Level AAA + + + +- **2.5.5 Target Size (Enhanced), 44 px.** Chips are 24 or 32 px high, and the delete icon is 16 or 22 px. `🚩` +- **2.4.13 Focus Appearance.** The focused background differs from the resting background by `1.13:1` to `1.92:1`, which does not meet it. `🚩` + + + +## Scope and test environment + +- **Standard.** WCAG 2.2, Level A and AA. +- **Component version.** `@mui/material` 10.0.0-alpha.0. + + + +- **Scope.** The Chip component in isolation, rendered through its documented API. +- **Automated.** axe-core in the Playwright test harness, on the Chip demos and fixtures in [`chips.a11y.json`](../../../../docs/data/material/components/chips/chips.a11y.json). Interaction and contrast tests are in `Chip.test.js` and `ButtonBase.test.js`. +- **Assistive-technology review.** Not done yet. The flagged criteria come from a review of the source. A review with NVDA, JAWS, and VoiceOver must still confirm them. + + diff --git a/packages/mui-material/src/accessibility.md b/packages/mui-material/src/accessibility.md index e794f5933ebd50..2104632f7769d4 100644 --- a/packages/mui-material/src/accessibility.md +++ b/packages/mui-material/src/accessibility.md @@ -189,6 +189,7 @@ Edit the JSON files, not this table. | [Button](./Button/accessibility.md) | 23 | 5 | 0 | 27 | — | 9/28 | | [ButtonGroup](./ButtonGroup/accessibility.md) | 7 | 2 | 0 | 27 | 19 | 3/9 | | [Checkbox](./Checkbox/accessibility.md) | 24 | 1 | 0 | 30 | — | 3/25 | +| [Chip](./Chip/accessibility.md) | 16 | 7 | 1 | 31 | — | 9/24 | | [CircularProgress](./CircularProgress/accessibility.md) | 8 | 3 | 0 | 44 | — | 5/11 | | [Fab](./Fab/accessibility.md) | 21 | 4 | 0 | 30 | — | 6/25 | | [FormGroup](./FormGroup/accessibility.md) | 7 | 0 | 0 | 48 | — | 3/7 | diff --git a/packages/mui-material/src/manual-testing.md b/packages/mui-material/src/manual-testing.md index 1adfc7cb2c2b42..d8fd72afe23afd 100644 --- a/packages/mui-material/src/manual-testing.md +++ b/packages/mui-material/src/manual-testing.md @@ -18,14 +18,14 @@ the component (○ Author). Run the rows matching what you touched, for the component you touched. -| If your change touches… | Re-check | -| :----------------------------------- | :------------------------------------------------------------------------------------------------------------------------------- | -| Styling, theme, or palette | 1.4.1 Use of Color; 1.4.3 Contrast (Minimum); 1.4.5 Images of Text; 1.4.10 Reflow; 1.4.11 Non-text Contrast; 1.4.12 Text Spacing | -| DOM structure, roles, or ARIA | 1.1.1 Non-text Content; 1.3.1 Info and Relationships; 1.3.2 Meaningful Sequence; 4.1.2 Name, Role, Value; 4.1.3 Status Messages | -| Keyboard, focus, or pointer handling | 2.4.3 Focus Order; 2.4.4 Link Purpose (In Context); 2.4.6 Headings and Labels; 2.4.7 Focus Visible; 2.5.8 Target Size (Minimum) | -| Labels, errors, or validation | 3.3.2 Labels or Instructions | -| Motion or timing | 2.2.2 Pause, Stop, Hide | -| Other | 2.3.1 Three Flashes or Below Threshold | +| If your change touches… | Re-check | +| :----------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------- | +| Styling, theme, or palette | 1.4.1 Use of Color; 1.4.3 Contrast (Minimum); 1.4.5 Images of Text; 1.4.10 Reflow; 1.4.11 Non-text Contrast; 1.4.12 Text Spacing | +| DOM structure, roles, or ARIA | 1.1.1 Non-text Content; 1.3.1 Info and Relationships; 1.3.2 Meaningful Sequence; 4.1.2 Name, Role, Value; 4.1.3 Status Messages | +| Keyboard, focus, or pointer handling | 2.1.1 Keyboard; 2.4.3 Focus Order; 2.4.4 Link Purpose (In Context); 2.4.6 Headings and Labels; 2.4.7 Focus Visible; 2.5.8 Target Size (Minimum) | +| Labels, errors, or validation | 3.3.2 Labels or Instructions | +| Motion or timing | 2.2.2 Pause, Stop, Hide | +| Other | 2.3.1 Three Flashes or Below Threshold | ## Accordion @@ -105,6 +105,25 @@ Run the rows matching what you touched, for the component you touched. - [ ] 🔁 **3.3.2 Labels or Instructions** — every checkbox has a label or instruction presented to all users, via `FormControlLabel`, adjacent text, or clear context. - [ ] 🔁 **4.1.2 Name, Role, Value** — the role, the checked/unchecked/mixed/disabled state with change notification, and an author-supplied accessible name are all programmatically determinable. +## Chip + +14 checks · full procedures in [`Chip/accessibility.md`](./Chip/accessibility.md) + +- [ ] 🔁 **1.1.1 Non-text Content** — the screen reader tells the user that the chip can be deleted. Expected result from the source: it does not. To fix it, add a description with `aria-describedby`. +- [ ] 🔁 **1.3.1 Info and Relationships** — each chip announces the correct role, and a list of chips is announced as a list. +- [ ] 🔁 **1.4.1 Use of Color** — the meaning and the state of each chip stay clear without color. +- [ ] 🔁 **1.4.3 Contrast (Minimum)** — each label is at least `4.5:1` at rest, on hover, and on focus. `info` and `warning` fail. On an `outlined` chip, all focused labels except `secondary` fail, and the hovered `primary` label fails. +- [ ] 🔁 **1.4.10 Reflow** — the full label stays visible. A long label fails with the default styles. +- [ ] 🔁 **1.4.11 Non-text Contrast** — the delete icon and the focus indicator are at least `3:1`. The `outlined` border does not need `3:1`, because the label identifies the chip. It is `1.88:1` (default) and `2.23:1` to `3.57:1` (palette). The default delete icon and focus indicator fail. +- [ ] 🔁 **1.4.12 Text Spacing** — the full label stays visible. A long label fails with the default styles. +- [ ] 🔁 **2.1.1 Keyboard** — the deletable chip is removed, and the clickable chip activates on each key. +- [ ] 🔁 **2.4.3 Focus Order** — focus moves to a nearby chip or control, not to the top of the page. The ChipsArray demo fails. +- [ ] 🔁 **2.4.4 Link Purpose (In Context)** — the destination of each link chip is clear. +- [ ] 🔁 **2.4.6 Headings and Labels** — each label describes the item or the filter. +- [ ] 🔁 **2.4.7 Focus Visible** — each focused chip shows a visible change. +- [ ] 🔁 **2.5.8 Target Size (Minimum)** — the delete icon is at least 24 by 24 CSS px. Or, a 24 px circle on its center touches no other target. The default icon is 22 by 22 px on a `medium` chip, and 16 by 16 px on a `small` chip. +- [ ] 🔁 **4.1.2 Name, Role, Value** — each chip announces its label and "button". The disabled chip announces "disabled". The disabled delete-only chip fails. + ## CircularProgress 8 checks · full procedures in [`CircularProgress/accessibility.md`](./CircularProgress/accessibility.md) diff --git a/scripts/a11yScorecard/render.mjs b/scripts/a11yScorecard/render.mjs index a2667e21e8f42c..cd676d06c24cac 100644 --- a/scripts/a11yScorecard/render.mjs +++ b/scripts/a11yScorecard/render.mjs @@ -238,7 +238,7 @@ export function renderDocsRollup(totals) { const headline = totals.doesNotSupport === 0 ? '**No component records a ❌ Does Not Support rating for any Level A or AA criterion.**' - : `**${totals.doesNotSupport} criteria record a ❌ Does Not Support rating in at least one component.**`; + : `**${totals.doesNotSupport} ${totals.doesNotSupport === 1 ? 'criterion records' : 'criteria record'} a ❌ Does Not Support rating in at least one component.**`; return [ headline, '', @@ -252,13 +252,13 @@ export function renderDocsRollup(totals) { */ export function renderDocsTable(reports) { const header = [ - '| Component | Level A | Level AA | Rated | ✅ Supports | ⚠️ Partially Supports | Verified | Automated |', - '| :-------- | ------: | -------: | ----: | ----------: | --------------------: | -------: | --------: |', + '| Component | Level A | Level AA | Rated | ✅ Supports | ⚠️ Partially Supports | ❌ Does Not Support | Verified | Automated |', + '| :-------- | ------: | -------: | ----: | ----------: | --------------------: | ------------------: | -------: | --------: |', ]; const rows = reports.map(({ component, summary }) => { const link = `[${component}](${REPORT_BASE}/${component}/accessibility.md)`; - return `| ${link} | ${summary.levelA} | ${summary.levelAA} | ${summary.rated} | ${summary.supports} | ${summary.partiallySupports} | ${summary.verified}/${summary.rated} | ${summary.automated} |`; + return `| ${link} | ${summary.levelA} | ${summary.levelAA} | ${summary.rated} | ${summary.supports} | ${summary.partiallySupports} | ${summary.doesNotSupport} | ${summary.verified}/${summary.rated} | ${summary.automated} |`; }); return [...header, ...rows].join('\n'); diff --git a/test/regressions/a11y/criteriaSuites.mjs b/test/regressions/a11y/criteriaSuites.mjs index 8ce27b45250ed6..ced4a11e77d1ac 100644 --- a/test/regressions/a11y/criteriaSuites.mjs +++ b/test/regressions/a11y/criteriaSuites.mjs @@ -20,6 +20,7 @@ export const CSS_LAYOUT_SUITES = [ { component: 'Button', route: '/docs-components-buttons/BasicButtons' }, { component: 'ButtonGroup', route: '/docs-components-button-group/VariantButtonGroup' }, { component: 'Checkbox', route: '/docs-components-checkboxes/Checkboxes' }, + { component: 'Chip', route: '/docs-components-chips/ChipsArray' }, { component: 'CircularProgress', route: '/docs-components-progress/CircularDeterminate', @@ -86,6 +87,11 @@ export const FOCUS_VISIBLE_TARGETS = [ route: '/docs-components-checkboxes/Checkboxes', selector: '.MuiCheckbox-root', }, + { + component: 'Chip', + route: '/docs-components-chips/ClickableChips', + selector: '.MuiChip-clickable', + }, { component: 'Fab', route: '/docs-components-floating-action-button/FloatingActionButtons', diff --git a/test/regressions/a11y/fixtures/chips/ChipA11yColorMatrix.js b/test/regressions/a11y/fixtures/chips/ChipA11yColorMatrix.js new file mode 100644 index 00000000000000..6b1ed6ca3247c7 --- /dev/null +++ b/test/regressions/a11y/fixtures/chips/ChipA11yColorMatrix.js @@ -0,0 +1,19 @@ +import Box from '@mui/material/Box'; +import Chip from '@mui/material/Chip'; + +const variants = ['filled', 'outlined']; +const colors = ['default', 'primary', 'secondary', 'success', 'error', 'info', 'warning']; + +export default function ChipA11yColorMatrix() { + return ( + div': { display: 'flex', flexWrap: 'wrap', gap: 1 } }}> + {variants.map((variant) => ( +
    + {colors.map((color) => ( + + ))} +
    + ))} +
    + ); +} diff --git a/test/regressions/a11y/fixtures/chips/ChipA11yKnownGaps.js b/test/regressions/a11y/fixtures/chips/ChipA11yKnownGaps.js new file mode 100644 index 00000000000000..d8485151b2a2ab --- /dev/null +++ b/test/regressions/a11y/fixtures/chips/ChipA11yKnownGaps.js @@ -0,0 +1,14 @@ +import Stack from '@mui/material/Stack'; +import Chip from '@mui/material/Chip'; + +const noop = () => {}; + +// Documented gap: a disabled delete-only chip has no `aria-disabled`, so axe +// rates its faded label as an active control (4.1.2). +export default function ChipA11yKnownGaps() { + return ( + + + + ); +} diff --git a/test/regressions/a11y/fixtures/chips/ChipA11yLongLabel.js b/test/regressions/a11y/fixtures/chips/ChipA11yLongLabel.js new file mode 100644 index 00000000000000..3af9e38a8538fa --- /dev/null +++ b/test/regressions/a11y/fixtures/chips/ChipA11yLongLabel.js @@ -0,0 +1,27 @@ +import Stack from '@mui/material/Stack'; +import Chip from '@mui/material/Chip'; + +const noop = () => {}; + +// The label does not wrap, so it ends with an ellipsis when the chip is too +// narrow. The first chip fits its 240px container at 100% text size. The second +// fits a wide viewport but not 320 CSS px. The third uses the wrapping styles +// from the MultilineChips docs demo. +export default function ChipA11yLongLabel() { + return ( + + + + + + + + ); +} diff --git a/test/regressions/a11y/fixtures/chips/ChipA11ySemanticStates.js b/test/regressions/a11y/fixtures/chips/ChipA11ySemanticStates.js new file mode 100644 index 00000000000000..1967cce680d0cf --- /dev/null +++ b/test/regressions/a11y/fixtures/chips/ChipA11ySemanticStates.js @@ -0,0 +1,27 @@ +import Stack from '@mui/material/Stack'; +import Chip from '@mui/material/Chip'; +import FaceIcon from '@mui/icons-material/Face'; + +const noop = () => {}; + +export default function ChipA11ySemanticStates() { + return ( + + + + + + + + + + + + + + + } label="With icon" variant="outlined" /> + + + ); +} diff --git a/test/regressions/demoMeta.test.ts b/test/regressions/demoMeta.test.ts index 4d972d39926a2a..82e94638e65fce 100644 --- a/test/regressions/demoMeta.test.ts +++ b/test/regressions/demoMeta.test.ts @@ -232,6 +232,30 @@ describe('getConfig', () => { ).to.deep.include({ enabled: true, assertions: 'all' }); }); + it('asserts every rule on the Chip demos and records only the documented contrast gaps', () => { + expect(getConfig(A11Y_RULES, 'docs/data/material/components/chips/BasicChips')).to.deep.include( + { + enabled: true, + assertions: 'all', + }, + ); + expect( + getConfig(A11Y_RULES, 'docs/data/material/components/chips/BasicChips'), + ).not.to.have.property('skipAssertions'); + expect( + getConfig(A11Y_RULES, 'docs/data/material/components/chips/AvatarChips'), + ).not.to.have.property('skipAssertions'); + expect( + getConfig(A11Y_RULES, 'test/regressions/a11y/fixtures/chips/ChipA11ySemanticStates'), + ).not.to.have.property('skipAssertions'); + expect( + getConfig(A11Y_RULES, 'test/regressions/a11y/fixtures/chips/ChipA11yKnownGaps'), + ).to.deep.include({ skipAssertions: ['color-contrast'] }); + expect(getConfig(A11Y_RULES, 'docs/data/material/components/chips/ChipsPlayground')).to.equal( + undefined, + ); + }); + it('asserts every rule on the FormGroup fixture', () => { expect( getConfig(A11Y_RULES, 'test/regressions/a11y/fixtures/checkboxes/FormGroupA11yStates'), diff --git a/test/regressions/demoMeta.ts b/test/regressions/demoMeta.ts index b8605881c0e11f..08973119dd7ff5 100644 --- a/test/regressions/demoMeta.ts +++ b/test/regressions/demoMeta.ts @@ -308,6 +308,22 @@ const BUTTON_GROUP_A11Y_DEMOS = [ 'SplitButton', ]; +// Chip docs demos enrolled for axe assertions. ChipsPlayground needs Redux isolation. +const CHIP_A11Y_DEMOS = [ + 'BasicChips', + 'ClickableChips', + 'DeletableChips', + 'ClickableAndDeletableChips', + 'ClickableLinkChips', + 'CustomDeleteIconChips', + 'AvatarChips', + 'IconChips', + 'ColorChips', + 'SizesChips', + 'MultilineChips', + 'ChipsArray', +]; + // Fab docs demos enrolled for axe assertions. FloatingActionButtonZoom is excluded: // most of its content is a Tabs component. const FAB_A11Y_DEMOS = [ @@ -576,6 +592,28 @@ export const A11Y_RULES: A11yRule[] = [ assertions: 'all', skipAssertions: ['color-contrast'], }, + { + test: `docs/data/material/components/chips/{${CHIP_A11Y_DEMOS.join(',')}}`, + enabled: true, + assertions: 'all', + }, + // A11y-only fixtures under `test/regressions/a11y/fixtures/chips/`; the suite + // name maps their results into the same `chips.a11y.json`. + { + test: 'test/regressions/a11y/fixtures/chips/{ChipA11ySemanticStates,ChipA11yLongLabel}', + enabled: true, + assertions: 'all', + }, + // `color-contrast` is recorded but not asserted. These are documented gaps + // in `packages/mui-material/src/Chip/accessibility.md`: the `info` and `warning` + // labels (1.4.3). axe also fails the faded label of a disabled delete-only chip, + // because the chip has no `aria-disabled` (4.1.2). + { + test: 'test/regressions/a11y/fixtures/chips/{ChipA11yColorMatrix,ChipA11yKnownGaps}', + enabled: true, + assertions: 'all', + skipAssertions: ['color-contrast'], + }, { test: `docs/data/material/components/links/{${LINK_A11Y_DEMOS.join(',')}}`, enabled: true, diff --git a/test/regressions/fixtures/FocusVisible/KeyboardRing.js b/test/regressions/fixtures/FocusVisible/KeyboardRing.js index 065fec3d20019c..f095f633dfcd63 100644 --- a/test/regressions/fixtures/FocusVisible/KeyboardRing.js +++ b/test/regressions/fixtures/FocusVisible/KeyboardRing.js @@ -5,6 +5,7 @@ import AccordionDetails from '@mui/material/AccordionDetails'; import AccordionSummary from '@mui/material/AccordionSummary'; import Button from '@mui/material/Button'; import Checkbox from '@mui/material/Checkbox'; +import Chip from '@mui/material/Chip'; import Fab from '@mui/material/Fab'; import IconButton from '@mui/material/IconButton'; import Radio from '@mui/material/Radio'; @@ -46,6 +47,7 @@ export default function KeyboardRing() { + {}} /> diff --git a/test/regressions/index.test.js b/test/regressions/index.test.js index b8b239833ccf9e..de0dd9ba193ece 100644 --- a/test/regressions/index.test.js +++ b/test/regressions/index.test.js @@ -552,6 +552,74 @@ async function main() { }); }); }); + describe('Chip', () => { + // A tripwire for the text-only resize limitation (1.4.4) and the 1.4.10 and + // 1.4.12 gaps: the label does not wrap, so text that fits ends with an ellipsis. When + // this fails, Chip wraps its label: update Chip/accessibility.md and knownGaps.json. + const ROUTE = '/a11y-chips/ChipA11yLongLabel'; + const truncated = (page, index) => + page.evaluate((i) => { + const label = document.querySelectorAll('.MuiChip-label')[i]; + return label.scrollWidth > label.clientWidth + 1; + }, index); + const whiteSpace = (page, index) => + page.evaluate( + (i) => getComputedStyle(document.querySelectorAll('.MuiChip-label')[i]).whiteSpace, + index, + ); + + test('known gap: a label that fits at 100% is truncated at 200% text-only resize and with WCAG text spacing', async ({ + pooled, + }) => { + const { page } = pooled; + await renderFixture(page, ROUTE); + if (await truncated(page, 0)) { + throw new Error('ChipA11yLongLabel no longer fits at 100%; pick a shorter label'); + } + // The spacing step has about 5 px of margin, so also pin the cause: the label does not wrap. + if ((await whiteSpace(page, 0)) !== 'nowrap') { + throw new Error('Chip label can wrap now; the gap may be fixed'); + } + for (const css of [ + 'html { font-size: 200% !important; }', + '* { line-height: 1.5 !important; letter-spacing: 0.12em !important; word-spacing: 0.16em !important; }', + ]) { + // eslint-disable-next-line no-await-in-loop + const style = await page.addStyleTag({ content: css }); + // Remove the style also when the check throws. The page is pooled, and + // the style would change the tests that use the page later. + try { + // eslint-disable-next-line no-await-in-loop + if (!(await truncated(page, 0))) { + throw new Error(`Chip label no longer truncates with ${css}; the gap may be fixed`); + } + } finally { + // eslint-disable-next-line no-await-in-loop + await style.evaluate((node) => node.remove()); + } + } + }); + + test('known gap: a label that fits a wide viewport is truncated at 320 CSS px', async ({ + pooled, + }) => { + const { page } = pooled; + await renderFixture(page, ROUTE); + if (await truncated(page, 1)) { + throw new Error('ChipA11yLongLabel no longer fits at the default viewport'); + } + await page.setViewportSize({ width: 320, height: 512 }); + try { + await renderFixture(page, ROUTE); + if (!(await truncated(page, 1))) { + throw new Error('Chip label no longer truncates at 320 CSS px; the gap may be fixed'); + } + } finally { + await page.setViewportSize(DEFAULT_VIEWPORT); + } + }); + }); + describe('Avatar', () => { // Deterministic clip check for 1.4.12 Text Spacing, which axe cannot cover. // Renders `LetterAvatars` and targets the two-character ("OP") avatar, @@ -889,6 +957,7 @@ function registerFocusVisibleSuites({ test, renderFixture, routes }) { { 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: 'Chip', route: RING_ROUTE, selector: '.MuiChip-clickable' }, { component: 'IconButton', route: RING_ROUTE, selector: '.MuiIconButton-root' }, { component: 'Radio', route: RING_ROUTE, selector: '.MuiRadio-root' }, { component: 'Switch', route: RING_ROUTE, selector: '.MuiSwitch-root' },