Skip to content

Commit 8637f66

Browse files
crisbetojelbourn
authored andcommitted
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. (cherry picked from commit 1c2300f)
1 parent 9f14e62 commit 8637f66

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)