fix(forms): fix SelectControlValueAccessor not to call onChange twice
Closes #5969
This commit is contained in:
parent
a038bb9ae3
commit
b44d36cf95
@ -36,11 +36,7 @@ export class NgSelectOption {
|
|||||||
*/
|
*/
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: 'select[ngControl],select[ngFormControl],select[ngModel]',
|
selector: 'select[ngControl],select[ngFormControl],select[ngModel]',
|
||||||
host: {
|
host: {'(input)': 'onChange($event.target.value)', '(blur)': 'onTouched()'},
|
||||||
'(change)': 'onChange($event.target.value)',
|
|
||||||
'(input)': 'onChange($event.target.value)',
|
|
||||||
'(blur)': 'onTouched()'
|
|
||||||
},
|
|
||||||
bindings: [SELECT_VALUE_ACCESSOR]
|
bindings: [SELECT_VALUE_ACCESSOR]
|
||||||
})
|
})
|
||||||
export class SelectControlValueAccessor implements ControlValueAccessor {
|
export class SelectControlValueAccessor implements ControlValueAccessor {
|
||||||
|
@ -348,7 +348,7 @@ export function main() {
|
|||||||
expect(sfOption.nativeElement.selected).toBe(true);
|
expect(sfOption.nativeElement.selected).toBe(true);
|
||||||
|
|
||||||
select.nativeElement.value = 'NYC';
|
select.nativeElement.value = 'NYC';
|
||||||
dispatchEvent(select.nativeElement, "change");
|
dispatchEvent(select.nativeElement, "input");
|
||||||
|
|
||||||
expect(fixture.debugElement.componentInstance.form.value).toEqual({"city": 'NYC'});
|
expect(fixture.debugElement.componentInstance.form.value).toEqual({"city": 'NYC'});
|
||||||
expect(sfOption.nativeElement.selected).toBe(false);
|
expect(sfOption.nativeElement.selected).toBe(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user