Skip to content

Commit

Permalink
fix(module:select): fix not blur when user hits enter
Browse files Browse the repository at this point in the history
close NG-ZORRO#1940

The other problem in this issue would be fix in another pr.
  • Loading branch information
Wendell committed Aug 8, 2018
1 parent f4a8532 commit 486e1e7
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(); // If user hits enter key to select an option, focus status on the input element would not be removed by clicking event.
}
}

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 486e1e7

Please sign in to comment.