Skip to content

Commit

Permalink
fix(module:select): fix select search display (NG-ZORRO#3324)
Browse files Browse the repository at this point in the history
  • Loading branch information
vthinkxie authored and andrew-yangy committed Jun 20, 2019
1 parent 0723ce7 commit c2e885d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions components/select/nz-select-top-control.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class NzSelectTopControlComponent implements OnInit, OnDestroy {
}
}

removeSelectedValue(option: NzOptionComponent, e: KeyboardEvent): void {
removeSelectedValue(option: NzOptionComponent, e: MouseEvent): void {
this.nzSelectService.removeValueFormSelected(option);
e.stopPropagation();
}
Expand All @@ -137,7 +137,7 @@ export class NzSelectTopControlComponent implements OnInit, OnDestroy {
ngOnInit(): void {
this.nzSelectService.open$.pipe(takeUntil(this.destroy$)).subscribe(open => {
if (this.inputElement && open) {
this.inputElement.nativeElement.focus();
setTimeout(() => this.inputElement.nativeElement.focus());
}
});
this.nzSelectService.clearInput$.pipe(takeUntil(this.destroy$)).subscribe(() => {
Expand Down
8 changes: 5 additions & 3 deletions components/select/nz-select-top-control.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, DebugElement } from '@angular/core';
import { fakeAsync, flush, ComponentFixture, TestBed } from '@angular/core/testing';
import { fakeAsync, flush, tick, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Subject } from 'rxjs';
Expand Down Expand Up @@ -128,7 +128,7 @@ describe('nz-select top control', () => {
expect(tcComponent.selectedValueStyle.display).toBe('block');
expect(tcComponent.selectedValueStyle.opacity).toBe('0.4');
});
it('should open focus', () => {
it('should open focus', fakeAsync(() => {
fixture.detectChanges();
expect(tc.nativeElement.querySelector('.ant-select-search__field') === document.activeElement).toBeFalsy();
// @ts-ignore
Expand All @@ -138,8 +138,10 @@ describe('nz-select top control', () => {
// @ts-ignore
nzSelectService.open$.next(true);
fixture.detectChanges();
tick();
fixture.detectChanges();
expect(tc.nativeElement.querySelector('.ant-select-search__field') === document.activeElement).toBeTruthy();
});
}));
it('should destroy piped', () => {
fixture.detectChanges();
// @ts-ignore
Expand Down

0 comments on commit c2e885d

Please sign in to comment.