Skip to content

Commit

Permalink
fix(material/checkbox): add aria-checked (#27970)
Browse files Browse the repository at this point in the history
* fix(material/checkbox): add aria-checked

* fix(material/checkbox): move aria-checked test

(cherry picked from commit cc2f2c5)
  • Loading branch information
andrewseguin committed Oct 23, 2023
1 parent d74e508 commit 215b92a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/material/checkbox/checkbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[attr.aria-label]="ariaLabel || null"
[attr.aria-labelledby]="ariaLabelledby"
[attr.aria-describedby]="ariaDescribedby"
[attr.aria-checked]="indeterminate ? 'mixed' : null"
[attr.name]="name"
[attr.value]="value"
[checked]="checked"
Expand Down
9 changes: 3 additions & 6 deletions src/material/checkbox/checkbox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ describe('MDC-based MatCheckbox', () => {

expect(checkboxInstance.checked).toBe(true);
expect(inputElement.checked).toBe(true);
expect(inputElement.hasAttribute('aria-checked'))
.withContext('Expect aria-checked attribute to not be used')
.toBe(false);

testComponent.isChecked = false;
fixture.detectChanges();
Expand Down Expand Up @@ -103,9 +106,6 @@ describe('MDC-based MatCheckbox', () => {

expect(inputElement.checked).toBe(false);
expect(inputElement.indeterminate).toBe(true);
expect(inputElement.hasAttribute('aria-checked'))
.withContext('Expect aria-checked attribute to not be used')
.toBe(false);

testComponent.isIndeterminate = false;
fixture.detectChanges();
Expand Down Expand Up @@ -145,9 +145,6 @@ describe('MDC-based MatCheckbox', () => {
expect(inputElement.indeterminate).toBe(true);
expect(inputElement.checked).toBe(true);
expect(testComponent.isIndeterminate).toBe(true);
expect(inputElement.hasAttribute('aria-checked'))
.withContext('Expect aria-checked attribute to not be used')
.toBe(false);

inputElement.click();
fixture.detectChanges();
Expand Down

0 comments on commit 215b92a

Please sign in to comment.