Skip to content

Commit

Permalink
fix(module:input-number): fix touched event (#1858)
Browse files Browse the repository at this point in the history
close #1785
  • Loading branch information
vthinkxie authored and 执衡 committed Jul 22, 2018
1 parent 3532bbe commit 7c90a72
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/input-number/nz-input-number.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export class NzInputNumberComponent implements ControlValueAccessor, AfterViewIn
}

onBlur(e: FocusEvent): void {
this.onTouched();
this.isFocused = false;
const value = this.getCurrentValidValue(this.actualValue);
this.setValue(value, `${this.value}` !== `${value}`);
Expand Down
3 changes: 3 additions & 0 deletions components/input-number/nz-input-number.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ describe('input number', () => {
});
it('should focus className correct', () => {
fixture.detectChanges();
expect(inputNumber.nativeElement.classList).toContain('ng-untouched');
dispatchFakeEvent(inputElement, 'focus');
fixture.detectChanges();
expect(inputNumber.nativeElement.classList).toContain('ng-untouched');
expect(inputNumber.nativeElement.classList).toContain('ant-input-number-focused');
dispatchFakeEvent(inputElement, 'blur');
fixture.detectChanges();
expect(inputNumber.nativeElement.classList).not.toContain('ant-input-number-focused');
expect(inputNumber.nativeElement.classList).toContain('ng-touched');
});
it('should nzSize work', () => {
testComponent.size = 'large';
Expand Down

0 comments on commit 7c90a72

Please sign in to comment.