@@ -20,6 +20,8 @@ import {
20
20
} from '@angular/core' ;
21
21
import { COMPOSITION_BUFFER_MODE , FormsModule } from '@angular/forms' ;
22
22
23
+ import { reqAnimFrame } from 'ng-zorro-antd/core/polyfill' ;
24
+
23
25
@Component ( {
24
26
selector : 'nz-select-search' ,
25
27
encapsulation : ViewEncapsulation . None ,
@@ -79,12 +81,14 @@ export class NzSelectSearchComponent implements AfterViewInit, OnChanges {
79
81
}
80
82
81
83
syncMirrorWidth ( ) : void {
82
- const mirrorDOM = this . mirrorElement ! . nativeElement ;
83
- const hostDOM = this . elementRef . nativeElement ;
84
- const inputDOM = this . inputElement . nativeElement ;
85
- this . renderer . removeStyle ( hostDOM , 'width' ) ;
86
- this . renderer . setProperty ( mirrorDOM , 'textContent' , `${ inputDOM . value } \u00a0` ) ;
87
- this . renderer . setStyle ( hostDOM , 'width' , `${ mirrorDOM . scrollWidth } px` ) ;
84
+ reqAnimFrame ( ( ) => {
85
+ const mirrorDOM = this . mirrorElement ! . nativeElement ;
86
+ const hostDOM = this . elementRef . nativeElement ;
87
+ const inputDOM = this . inputElement . nativeElement ;
88
+ this . renderer . removeStyle ( hostDOM , 'width' ) ;
89
+ this . renderer . setProperty ( mirrorDOM , 'textContent' , `${ inputDOM . value } \u00a0` ) ;
90
+ this . renderer . setStyle ( hostDOM , 'width' , `${ mirrorDOM . scrollWidth } px` ) ;
91
+ } ) ;
88
92
}
89
93
90
94
focus ( ) : void {
0 commit comments