Skip to content

Commit 96de088

Browse files
committed
fix(material/checkbox): hide decorative elements from assistive technology
Hides the checkbox's decorative elements from screen readers so they don't interfere.
1 parent d553a8a commit 96de088

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/material/checkbox/checkbox.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<div mat-internal-form-field [labelPosition]="labelPosition" (click)="_preventBubblingFromLabel($event)">
22
<div #checkbox class="mdc-checkbox">
33
<!-- Render this element first so the input is on top. -->
4-
<div class="mat-mdc-checkbox-touch-target" (click)="_onTouchTargetClick()"></div>
4+
<div
5+
class="mat-mdc-checkbox-touch-target"
6+
(click)="_onTouchTargetClick()"
7+
aria-hidden="true"></div>
58
<input #input
69
type="checkbox"
710
class="mdc-checkbox__native-control"
@@ -25,19 +28,20 @@
2528
(blur)="_onBlur()"
2629
(click)="_onInputClick()"
2730
(change)="_onInteractionEvent($event)"/>
28-
<div class="mdc-checkbox__ripple"></div>
29-
<div class="mdc-checkbox__background">
31+
<div class="mdc-checkbox__ripple" aria-hidden="true"></div>
32+
<div class="mdc-checkbox__background" aria-hidden="true">
3033
<svg class="mdc-checkbox__checkmark"
3134
focusable="false"
32-
viewBox="0 0 24 24"
33-
aria-hidden="true">
35+
viewBox="0 0 24 24">
3436
<path class="mdc-checkbox__checkmark-path"
3537
fill="none"
3638
d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
3739
</svg>
3840
<div class="mdc-checkbox__mixedmark"></div>
3941
</div>
40-
<div class="mat-mdc-checkbox-ripple mat-focus-indicator" mat-ripple
42+
<div class="mat-mdc-checkbox-ripple mat-focus-indicator"
43+
mat-ripple
44+
aria-hidden="true"
4145
[matRippleTrigger]="checkbox"
4246
[matRippleDisabled]="disableRipple || disabled"
4347
[matRippleCentered]="true"></div>

src/material/checkbox/checkbox.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ describe('MatCheckbox', () => {
5858
expect(inputElement.checked).toBe(false);
5959
}));
6060

61-
it('should hide the internal SVG', () => {
62-
const svg = checkboxNativeElement.querySelector('svg')!;
63-
expect(svg.getAttribute('aria-hidden')).toBe('true');
61+
it('should hide the decorative element', () => {
62+
const background = checkboxNativeElement.querySelector('.mdc-checkbox__background')!;
63+
expect(background.getAttribute('aria-hidden')).toBe('true');
6464
});
6565

6666
it('should toggle checkbox ripple disabledness correctly', fakeAsync(() => {

0 commit comments

Comments
 (0)