Skip to content

Commit

Permalink
feat(module:auto-complete): close panel when the trigger element blur (
Browse files Browse the repository at this point in the history
…#2916)

* feat(module:auto-complete): close panel when the trigger element blur

close #2885

* test(module:auto-complete): add the feat test
  • Loading branch information
hsuanxyz authored and vthinkxie committed Feb 19, 2019
1 parent abbf3b1 commit 1e075f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ export class NzAutocompleteTriggerDirective implements ControlValueAccessor, OnD
}

handleBlur(): void {
this.closePanel();
this._onTouched();
}

Expand Down
14 changes: 14 additions & 0 deletions components/auto-complete/nz-autocomplete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,20 @@ describe('auto-complete', () => {
.toBe(false);
}));

it('should close the panel when the trigger blur', fakeAsync(() => {
dispatchFakeEvent(input, 'focusin');
fixture.detectChanges();
flush();

expect(fixture.componentInstance.trigger.panelOpen)
.toBe(true);

dispatchFakeEvent(input, 'blur');

expect(fixture.componentInstance.trigger.panelOpen)
.toBe(false);
}));

it('should not close the panel when the user clicks this input', fakeAsync(() => {
dispatchFakeEvent(input, 'focusin');
fixture.detectChanges();
Expand Down

0 comments on commit 1e075f9

Please sign in to comment.