Skip to content

Commit c7ab828

Browse files
crisbetoandrewseguin
authored andcommitted
fix(select): multiple change events emitted when changing options of 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.
1 parent eb012cc commit c7ab828

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/lib/select/select.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,14 @@ describe('MatSelect', () => {
23362336

23372337
expect(fixture.componentInstance.changeListener).toHaveBeenCalledTimes(1);
23382338
});
2339+
2340+
it('should only emit one event when pressing the arrow keys on a closed select', () => {
2341+
const select = fixture.debugElement.query(By.css('md-select')).nativeElement;
2342+
dispatchKeyboardEvent(select, 'keydown', DOWN_ARROW);
2343+
2344+
expect(fixture.componentInstance.changeListener).toHaveBeenCalledTimes(1);
2345+
});
2346+
23392347
});
23402348

23412349
describe('floatPlaceholder option', () => {

src/lib/select/select.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,6 @@ export class MatSelect extends _MatSelectMixinBase implements AfterContentInit,
11351135
if (currentActiveItem !== prevActiveItem) {
11361136
this._clearSelection();
11371137
this._setSelectionByValue(currentActiveItem.value, true);
1138-
this._propagateChanges();
11391138
}
11401139
}
11411140
}

0 commit comments

Comments
 (0)