Skip to content

Commit

Permalink
fix(module:select): fix input not blur after user hits enter key (#1943)
Browse files Browse the repository at this point in the history
close #1940
  • Loading branch information
wendzhue authored and hsuanxyz committed Aug 19, 2018
1 parent 19fc2ee commit a64d04c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
12 changes: 0 additions & 12 deletions .vscode/launch.json

This file was deleted.

1 change: 1 addition & 0 deletions components/select/nz-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ export class NzSelectComponent implements ControlValueAccessor, OnInit, AfterVie
this.onTouched();
this.nzOpen = false;
this.nzOpenChange.emit(this.nzOpen);
this.blur();
}
}

Expand Down
12 changes: 12 additions & 0 deletions components/select/nz-select.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,18 @@ describe('nz-select component', () => {
fixture.detectChanges();
expect(testComponent.onSearch).toHaveBeenCalledTimes(1);
});
it('should blur after user hits enter key in single mode', () => {
const spy = spyOn(testComponent.nzSelectComponent, 'blur');
testComponent.showSearch = true;
select.nativeElement.click();
fixture.detectChanges();
dispatchKeyboardEvent(select.nativeElement.querySelector('.ant-select-selection'), 'keydown', 40);
fixture.detectChanges();
expect(spy).not.toHaveBeenCalled();
dispatchKeyboardEvent(select.nativeElement.querySelector('.ant-select-selection'), 'keydown', 13);
fixture.detectChanges();
expect(spy).toHaveBeenCalled();
});
});
describe('tags', () => {
let fixture;
Expand Down

0 comments on commit a64d04c

Please sign in to comment.