Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
442 changes: 442 additions & 0 deletions docs/data/material/components/button-group/button-group.a11y.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function SplitButton() {
<Button
size="small"
aria-controls={open ? 'split-button-menu' : undefined}
aria-expanded={open ? 'true' : undefined}
aria-expanded={open}
aria-label="select merge strategy"
aria-haspopup="menu"
onClick={handleToggle}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"affected": [
"AccordionSummary",
"Button",
"ButtonGroup",
"Checkbox",
{ "component": "Fab", "note": "the ring needs `disableFocusRipple`" },
{ "component": "IconButton", "note": "the ring needs `disableFocusRipple` too" },
Expand Down Expand Up @@ -38,6 +39,12 @@
],
"workaround": "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"
},
{
"gap": "A horizontal group does not wrap, so a wide group can scroll horizontally at 320 px",
"criteria": ["1.4.10"],
"affected": ["ButtonGroup", "ToggleButtonGroup"],
"workaround": "Set `orientation=\"vertical\"` on small screens"
},
{
"gap": "The selected state of colored Toggle Buttons is conveyed almost entirely by hue",
"criteria": ["1.4.1"],
Expand Down
161 changes: 154 additions & 7 deletions docs/data/material/getting-started/accessibility/scorecard.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"standard": "WCAG 2.2 Level A and AA",
"componentCount": 17,
"componentCount": 18,
"totals": {
"rated": 32,
"supports": 23,
Expand Down Expand Up @@ -96,7 +96,7 @@
"level": "AA",
"conformance": "Partially Supports",
"flagged": false,
"affected": ["Fab"]
"affected": ["ButtonGroup", "Fab", "ToggleButtonGroup"]
},
{
"number": "1.4.11",
Expand All @@ -108,6 +108,7 @@
"AccordionSummary",
"Avatar",
"Button",
"ButtonGroup",
"Checkbox",
"CircularProgress",
"Fab",
Expand Down Expand Up @@ -1174,6 +1175,147 @@
"automated": 10
}
},
{
"component": "ButtonGroup",
"counts": {
"supports": 7,
"partiallySupports": 2,
"doesNotSupport": 0,
"notApplicable": 27,
"inherited": 19,
"flagged": 3,
"rated": 9
},
"gaps": [
{
"number": "1.4.10",
"name": "Reflow",
"conformance": "Partially Supports"
},
{
"number": "1.4.11",
"name": "Non-text Contrast",
"conformance": "Partially Supports"
},
{
"number": "1.4.3",
"name": "Contrast (Minimum)",
"conformance": "Partially Supports",
"from": "Button"
},
{
"number": "2.2.2",
"name": "Pause, Stop, Hide",
"conformance": "Partially Supports",
"from": "Button"
},
{
"number": "2.4.3",
"name": "Focus Order",
"conformance": "Partially Supports",
"from": "Button"
},
{
"number": "4.1.3",
"name": "Status Messages",
"conformance": "Partially Supports",
"from": "Button"
}
],
"criteria": [
{
"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": "Shared",
"group": "Manual",
"flagged": true
},
{
"number": "1.4.4",
"name": "Resize Text",
"level": "AA",
"conformance": "Supports",
"responsibility": "Shared",
"group": "Automated",
"flagged": false
},
{
"number": "1.4.10",
"name": "Reflow",
"level": "AA",
"conformance": "Partially Supports",
"responsibility": "Shared",
"group": "Automated",
"flagged": false
},
{
"number": "1.4.11",
"name": "Non-text Contrast",
"level": "AA",
"conformance": "Partially Supports",
"responsibility": "Component",
"group": "Manual",
"flagged": true
},
{
"number": "1.4.12",
"name": "Text Spacing",
"level": "AA",
"conformance": "Supports",
"responsibility": "Shared",
"group": "Automated",
"flagged": false
},
{
"number": "2.4.6",
"name": "Headings and Labels",
"level": "AA",
"conformance": "Supports",
"responsibility": "Shared",
"group": "Manual",
"flagged": true
},
{
"number": "2.4.7",
"name": "Focus Visible",
"level": "AA",
"conformance": "Supports",
"responsibility": "Shared",
"group": "Hybrid",
"flagged": false
},
{
"number": "4.1.2",
"name": "Name, Role, Value",
"level": "A",
"conformance": "Supports",
"responsibility": "Shared",
"group": "Hybrid",
"flagged": false
}
],
"summary": {
"rated": 9,
"levelA": 3,
"levelAA": 6,
"supports": 7,
"partiallySupports": 2,
"doesNotSupport": 0,
"verified": 6,
"automated": 3
}
},
{
"component": "Checkbox",
"counts": {
Expand Down Expand Up @@ -3829,15 +3971,20 @@
{
"component": "ToggleButtonGroup",
"counts": {
"supports": 4,
"partiallySupports": 0,
"supports": 3,
"partiallySupports": 1,
"doesNotSupport": 0,
"notApplicable": 31,
"inherited": 20,
"flagged": 1,
"rated": 4
},
"gaps": [
{
"number": "1.4.10",
"name": "Reflow",
"conformance": "Partially Supports"
},
{
"number": "1.4.1",
"name": "Use of Color",
Expand Down Expand Up @@ -3871,7 +4018,7 @@
"number": "1.4.10",
"name": "Reflow",
"level": "AA",
"conformance": "Supports",
"conformance": "Partially Supports",
"responsibility": "Shared",
"group": "Automated",
"flagged": false
Expand Down Expand Up @@ -3899,8 +4046,8 @@
"rated": 4,
"levelA": 2,
"levelAA": 2,
"supports": 4,
"partiallySupports": 0,
"supports": 3,
"partiallySupports": 1,
"doesNotSupport": 0,
"verified": 3,
"automated": 1
Expand Down
115 changes: 115 additions & 0 deletions packages/mui-material/src/ButtonGroup/ButtonGroup.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { describe, it, expect } from 'vitest';
import * as React from 'react';
import {
act,
createRenderer,
Expand Down Expand Up @@ -393,4 +394,118 @@ describe('<ButtonGroup />', () => {
expect(saveButton).toHaveFocus();
});
});

describe('WCAG 2.2 conformance', () => {
describe('1.3.1 Info and Relationships', () => {
it('puts the buttons inside the group element', () => {
render(
<ButtonGroup>
<Button>Left</Button>
<Button>Right</Button>
</ButtonGroup>,
);

const group = screen.getByRole('group');
screen.getAllByRole('button').forEach((button) => {
expect(group).to.contain(button);
});
});
});

describe('2.4.3 Focus Order', () => {
it('moves through the buttons in DOM order', async () => {
const { user } = render(
<ButtonGroup aria-label="Actions">
<Button>One</Button>
<Button>Two</Button>
<Button>Three</Button>
</ButtonGroup>,
);

for (const name of ['One', 'Two', 'Three']) {
// eslint-disable-next-line no-await-in-loop
await user.tab();
expect(screen.getByRole('button', { name })).toHaveFocus();
}
});

it('removes the buttons of a disabled group from the tab order', async () => {
const { user } = render(
<React.Fragment>
<button type="button">Before</button>
<ButtonGroup disabled aria-label="Actions">
<Button>One</Button>
<Button>Two</Button>
</ButtonGroup>
<button type="button">After</button>
</React.Fragment>,
);

await user.tab();
await user.tab();
expect(screen.getByRole('button', { name: 'After' })).toHaveFocus();
});
});

// JSDOM doesn't support :focus-visible
it.skipIf(isJsdom())(
'2.4.7 Focus Visible: with the theme ring, the focused button paints above its neighbors',
async () => {
const { user } = render(
<ThemeProvider theme={createTheme({ focusVisible: true })}>
<ButtonGroup aria-label="Actions">
<Button>One</Button>
<Button>Two</Button>
</ButtonGroup>
</ThemeProvider>,
);

await user.tab();
const focused = screen.getByRole('button', { name: 'One' });
expect(focused).to.have.class(buttonClasses.focusVisible);
// The neighbors overlap by 1px, so a lower z-index would cover the ring edge.
expect(window.getComputedStyle(focused).zIndex).to.equal('1');
expect(
window.getComputedStyle(screen.getByRole('button', { name: 'Two' })).zIndex,
).to.equal('auto');
},
);

describe('4.1.2 Name, Role, Value', () => {
it('has the group role and the name from aria-label', () => {
render(
<ButtonGroup aria-label="Export format">
<Button>PDF</Button>
</ButtonGroup>,
);

expect(screen.getByRole('group')).toHaveAccessibleName('Export format');
});

it('passes the disabled state to each button', () => {
render(
<ButtonGroup disabled aria-label="Actions">
<Button>One</Button>
<Button>Two</Button>
</ButtonGroup>,
);

screen.getAllByRole('button').forEach((button) => {
expect(button).to.have.property('disabled', true);
});
});

it('keeps a button enabled when it sets disabled={false} in a disabled group', () => {
render(
<ButtonGroup disabled aria-label="Actions">
<Button disabled={false}>One</Button>
<Button>Two</Button>
</ButtonGroup>,
);

expect(screen.getByRole('button', { name: 'One' })).to.have.property('disabled', false);
expect(screen.getByRole('button', { name: 'Two' })).to.have.property('disabled', true);
});
});
});
});
15 changes: 15 additions & 0 deletions packages/mui-material/src/ButtonGroup/accessibility.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"axe": "docs/data/material/components/button-group/button-group.a11y.json",
"inherits": "Button",
"criteria": {
"1.3.1": {},
"1.3.2": { "responsibility": "Shared", "flagged": true },
"1.4.4": {},
"1.4.10": { "conformance": "Partially Supports" },
"1.4.11": { "group": "Manual" },
"1.4.12": {},
"2.4.6": { "group": "Manual", "flagged": true },
"2.4.7": {},
"4.1.2": {}
}
}
Loading
Loading