Skip to content

Commit

Permalink
fix(chips): being able to focus disabled chip by clicking (#8892)
Browse files Browse the repository at this point in the history
Fixes users being able to focus a disabled chip by clicking it.

Fixes #8883.
  • Loading branch information
crisbeto authored and jelbourn committed Jan 4, 2018
1 parent 7b78b74 commit bfd513d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/lib/chips/chip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ describe('Chips', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MatChipsModule],
declarations: [
BasicChip, SingleChip
],
declarations: [BasicChip, SingleChip],
providers: [{
provide: Directionality, useFactory: () => {
return {value: dir};
}
provide: Directionality, useFactory: () => ({value: dir})
}]
});

Expand Down Expand Up @@ -281,6 +277,15 @@ describe('Chips', () => {
expect(chipNativeElement.getAttribute('aria-disabled')).toBe('true');
});

it('should make disabled chips non-focusable', () => {
expect(chipNativeElement.getAttribute('tabindex')).toBe('-1');

testComponent.disabled = true;
fixture.detectChanges();

expect(chipNativeElement.getAttribute('tabindex')).toBeFalsy();
});

});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/lib/chips/chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class MatBasicChip {
exportAs: 'matChip',
host: {
'class': 'mat-chip',
'tabindex': '-1',
'[attr.tabindex]': 'disabled ? null : -1',
'role': 'option',
'[class.mat-chip-selected]': 'selected',
'[attr.disabled]': 'disabled || null',
Expand Down

0 comments on commit bfd513d

Please sign in to comment.