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
…NG-ZORRO#2916)

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

close NG-ZORRO#2885

* test(module:auto-complete): add the feat test
  • Loading branch information
hsuanxyz authored and Ricbet committed Apr 9, 2020
1 parent 7e64f5c commit 038001b
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 038001b

Please sign in to comment.