diff --git a/packages/forms/src/directives/number_value_accessor.ts b/packages/forms/src/directives/number_value_accessor.ts index dc85ae7b0d..2a2b8e50d1 100644 --- a/packages/forms/src/directives/number_value_accessor.ts +++ b/packages/forms/src/directives/number_value_accessor.ts @@ -43,11 +43,7 @@ export const NUMBER_VALUE_ACCESSOR: any = { @Directive({ selector: 'input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]', - host: { - '(change)': 'onChange($event.target.value)', - '(input)': 'onChange($event.target.value)', - '(blur)': 'onTouched()' - }, + host: {'(input)': 'onChange($event.target.value)', '(blur)': 'onTouched()'}, providers: [NUMBER_VALUE_ACCESSOR] }) export class NumberValueAccessor implements ControlValueAccessor { diff --git a/packages/forms/test/value_accessor_integration_spec.ts b/packages/forms/test/value_accessor_integration_spec.ts index 852e04bde4..b00207e377 100644 --- a/packages/forms/test/value_accessor_integration_spec.ts +++ b/packages/forms/test/value_accessor_integration_spec.ts @@ -149,6 +149,23 @@ import {dispatchEvent} from '@angular/platform-browser/testing/src/browser_util' expect(control.value).toEqual(0); }); + it('should ignore the change event', () => { + const fixture = initTest(FormControlNumberInput); + const control = new FormControl(); + fixture.componentInstance.control = control; + fixture.detectChanges(); + + control.valueChanges.subscribe({ + next: (value) => { + throw 'Input[number] should not react to change event'; + } + }); + const input = fixture.debugElement.query(By.css('input')); + + input.nativeElement.value = '5'; + dispatchEvent(input.nativeElement, 'change'); + }); + it('when value is cleared programmatically', () => { const fixture = initTest(FormControlNumberInput); const control = new FormControl(10);