Skip to content

Commit

Permalink
fix(select): reset option being marked as selected (#11934)
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto authored and josephperrott committed Jun 26, 2018
1 parent 548266b commit cd32d78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2580,6 +2580,18 @@ describe('MatSelect', () => {
expect(trigger.textContent).not.toContain('None');
}));

it('should not mark the reset option as selected ', fakeAsync(() => {
options[5].click();
fixture.detectChanges();
flush();

fixture.componentInstance.select.open();
fixture.detectChanges();
flush();

expect(options[5].classList).not.toContain('mat-selected');
}));

it('should not reset when any other falsy option is selected', fakeAsync(() => {
options[3].click();
fixture.detectChanges();
Expand Down
1 change: 1 addition & 0 deletions src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
const wasSelected = this._selectionModel.isSelected(option);

if (option.value == null && !this._multiple) {
option.deselect();
this._selectionModel.clear();
this._propagateChanges(option.value);
} else {
Expand Down

0 comments on commit cd32d78

Please sign in to comment.