Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(checkbox): set aria-checked of indeterminate checkbox to 'mixed' #29115

Merged
merged 1 commit into from Mar 6, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/components/checkbox/checkbox.tsx
Expand Up @@ -251,6 +251,7 @@ export class Checkbox implements ComponentInterface {

return (
<Host
aria-checked={indeterminate ? 'mixed' : `${checked}`}
class={createColorClasses(color, {
[mode]: true,
'in-item': hostContext('ion-item', el),
Expand Down
15 changes: 15 additions & 0 deletions core/src/components/checkbox/test/checkbox.spec.ts
Expand Up @@ -39,3 +39,18 @@ describe('ion-checkbox: disabled', () => {
expect(checkbox.checked).toBe(false);
});
});

describe('ion-checkbox: indeterminate', () => {
it('should have a mixed value for aria-checked', async () => {
const page = await newSpecPage({
components: [Checkbox],
html: `
<ion-checkbox indeterminate="true">Checkbox</ion-checkbox>
`,
});

const checkbox = page.body.querySelector('ion-checkbox')!;

expect(checkbox.getAttribute('aria-checked')).toBe('mixed');
});
});