@@ -33,8 +33,8 @@ import {
3333 ViewChild
3434} from '@angular/core' ;
3535import { ControlValueAccessor , NG_VALUE_ACCESSOR } from '@angular/forms' ;
36- import { merge , of as observableOf , Subject } from 'rxjs' ;
37- import { distinctUntilChanged , filter , map , takeUntil , tap , withLatestFrom } from 'rxjs/operators' ;
36+ import { combineLatest , merge , of as observableOf , Subject } from 'rxjs' ;
37+ import { distinctUntilChanged , filter , map , startWith , takeUntil , tap , withLatestFrom } from 'rxjs/operators' ;
3838
3939import { slideMotion } from 'ng-zorro-antd/core/animation' ;
4040import { NzConfigKey , NzConfigService , WithConfig } from 'ng-zorro-antd/core/config' ;
@@ -169,7 +169,7 @@ const listOfPositions = [
169169 [nzId]="nzId"
170170 [showInput]="nzShowSearch"
171171 (keydown)="onKeyDownInput($event)"
172- (isComposingChange)="isComposing = $event"
172+ (isComposingChange)="isComposingChange( $event) "
173173 (valueChange)="setInputValue($event)"
174174 [value]="inputValue"
175175 [mirrorSync]="isMultiple"
@@ -352,6 +352,9 @@ export class NzTreeSelectComponent extends NzTreeBase implements ControlValueAcc
352352 private destroy$ = new Subject < void > ( ) ;
353353 private isNzDisableFirstChange : boolean = true ;
354354
355+ private isComposingChange$ = new Subject < boolean > ( ) ;
356+ private searchValueChange$ = new Subject < string > ( ) ;
357+
355358 onChange : OnChangeType = _value => { } ;
356359 onTouched : OnTouchedType = ( ) => { } ;
357360
@@ -419,6 +422,17 @@ export class NzTreeSelectComponent extends NzTreeBase implements ControlValueAcc
419422 this . cdr . markForCheck ( ) ;
420423 }
421424 } ) ;
425+
426+ // setInputValue method executed earlier than isComposingChange
427+ combineLatest ( [ this . searchValueChange$ , this . isComposingChange$ . pipe ( startWith ( false ) ) ] )
428+ . pipe ( takeUntil ( this . destroy$ ) )
429+ . subscribe ( ( [ searchValue , isComposing ] ) => {
430+ this . isComposing = isComposing ;
431+ if ( ! isComposing ) {
432+ this . inputValue = searchValue ;
433+ this . updatePosition ( ) ;
434+ }
435+ } ) ;
422436 }
423437
424438 ngOnDestroy ( ) : void {
@@ -429,7 +443,7 @@ export class NzTreeSelectComponent extends NzTreeBase implements ControlValueAcc
429443 }
430444
431445 isComposingChange ( isComposing : boolean ) : void {
432- this . isComposing = isComposing ;
446+ this . isComposingChange$ . next ( isComposing ) ;
433447 }
434448
435449 setDisabledState ( isDisabled : boolean ) : void {
@@ -568,10 +582,7 @@ export class NzTreeSelectComponent extends NzTreeBase implements ControlValueAcc
568582 }
569583
570584 setInputValue ( value : string ) : void {
571- if ( ! this . isComposing ) {
572- this . inputValue = value ;
573- this . updatePosition ( ) ;
574- }
585+ this . searchValueChange$ . next ( value ) ;
575586 }
576587
577588 removeSelected ( node : NzTreeNode , emit : boolean = true ) : void {
0 commit comments