Skip to content

Commit b44d36c

Browse files
committed
fix(forms): fix SelectControlValueAccessor not to call onChange twice
Closes #5969
1 parent a038bb9 commit b44d36c

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

modules/angular2/src/common/forms/directives/select_control_value_accessor.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ export class NgSelectOption {
3636
*/
3737
@Directive({
3838
selector: 'select[ngControl],select[ngFormControl],select[ngModel]',
39-
host: {
40-
'(change)': 'onChange($event.target.value)',
41-
'(input)': 'onChange($event.target.value)',
42-
'(blur)': 'onTouched()'
43-
},
39+
host: {'(input)': 'onChange($event.target.value)', '(blur)': 'onTouched()'},
4440
bindings: [SELECT_VALUE_ACCESSOR]
4541
})
4642
export class SelectControlValueAccessor implements ControlValueAccessor {

modules/angular2/test/common/forms/integration_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export function main() {
348348
expect(sfOption.nativeElement.selected).toBe(true);
349349

350350
select.nativeElement.value = 'NYC';
351-
dispatchEvent(select.nativeElement, "change");
351+
dispatchEvent(select.nativeElement, "input");
352352

353353
expect(fixture.debugElement.componentInstance.form.value).toEqual({"city": 'NYC'});
354354
expect(sfOption.nativeElement.selected).toBe(false);

0 commit comments

Comments
 (0)