Skip to content

Commit 1c2300f

Browse files
authored
fix(material-experimental/mdc-chips): don't allow focus on checkmark icon (#18588)
On some browsers SVG elements default to being focusable, which means that currently users are able to tab into the checkmark icon of the MDC chip option. These changes make it so that the element isn't focusable.
1 parent 9262c63 commit 1c2300f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/material-experimental/mdc-chips/chip-option.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ng-content select="mat-chip-avatar, [matChipAvatar]"></ng-content>
1010
<div class="mdc-chip__checkmark" *ngIf="_chipListMultiple">
11-
<svg class="mdc-chip__checkmark-svg" viewBox="-2 -3 30 30">
11+
<svg class="mdc-chip__checkmark-svg" viewBox="-2 -3 30 30" focusable="false">
1212
<path class="mdc-chip__checkmark-path" fill="none" stroke="black"
1313
d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
1414
</svg>

src/material-experimental/mdc-chips/chip-option.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ describe('MDC-based Option Chips', () => {
231231
expect(chipNativeElement.getAttribute('aria-selected')).toBe('true');
232232
}));
233233

234+
it('should disable focus on the checkmark', fakeAsync(() => {
235+
// The checkmark is only shown in multi selection mode.
236+
testComponent.chipList.multiple = true;
237+
flush();
238+
fixture.detectChanges();
239+
240+
const checkmark = chipNativeElement.querySelector('.mdc-chip__checkmark-svg')!;
241+
expect(checkmark.getAttribute('focusable')).toBe('false');
242+
}));
243+
234244
});
235245

236246
describe('when selectable is false', () => {

0 commit comments

Comments
 (0)