Skip to content

Commit

Permalink
fix(select): multiple change events emitted when changing options of …
Browse files Browse the repository at this point in the history
…a closed select (#7232)

Prevents two change events being fired the same change when selecting an option via the arrow keys on a closed select.

Fixes #7227.
  • Loading branch information
crisbeto authored and andrewseguin committed Sep 29, 2017
1 parent eb012cc commit c7ab828
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/lib/select/select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2336,6 +2336,14 @@ describe('MatSelect', () => {

expect(fixture.componentInstance.changeListener).toHaveBeenCalledTimes(1);
});

it('should only emit one event when pressing the arrow keys on a closed select', () => {
const select = fixture.debugElement.query(By.css('md-select')).nativeElement;
dispatchKeyboardEvent(select, 'keydown', DOWN_ARROW);

expect(fixture.componentInstance.changeListener).toHaveBeenCalledTimes(1);
});

});

describe('floatPlaceholder option', () => {
Expand Down
1 change: 0 additions & 1 deletion src/lib/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
if (currentActiveItem !== prevActiveItem) {
this._clearSelection();
this._setSelectionByValue(currentActiveItem.value, true);
this._propagateChanges();
}
}
}
Expand Down

0 comments on commit c7ab828

Please sign in to comment.