@@ -91,7 +91,7 @@ export class TlAutoComplete extends ValueAccessorBase<any> implements OnChanges,
91
91
92
92
@Input ( ) openFocus = true ;
93
93
94
- @Input ( ) loading = true ;
94
+ @Input ( ) loading = false ;
95
95
96
96
@Input ( ) clearButton = true ;
97
97
@@ -226,16 +226,14 @@ export class TlAutoComplete extends ValueAccessorBase<any> implements OnChanges,
226
226
private handleItemSelected ( ) {
227
227
if ( this . itemSelectedService . itemSelected ) {
228
228
this . scrollToIndex ( ) . then ( value => {
229
- setTimeout ( ( ) => {
230
- this . keyManager . setActiveItem ( this . itemSelectedService . itemSelected . indexSelected ) ;
231
- } , 200 ) ;
229
+ this . keyManager . setActiveItem ( this . itemSelectedService . itemSelected . indexSelected ) ;
232
230
} ) ;
233
231
}
234
232
}
235
233
236
234
237
235
private scrollToIndex ( ) {
238
- return new Promise ( ( resolve , reject ) => {
236
+ return new Promise ( ( resolve ) => {
239
237
setTimeout ( ( ) => {
240
238
if ( this . cdkVirtualScroll ) {
241
239
this . cdkVirtualScroll . scrollToIndex ( this . lastItemScrolled ) ;
@@ -347,6 +345,10 @@ export class TlAutoComplete extends ValueAccessorBase<any> implements OnChanges,
347
345
}
348
346
349
347
handleKeyArrowDown ( $event ) {
348
+ if ( this . loading ) {
349
+ this . stopEvent ( $event ) ;
350
+ return ;
351
+ }
350
352
this . handleEventOpenList ( $event ) ;
351
353
if ( ! this . keyManager . activeItem ) {
352
354
this . keyManager . setFirstItemActive ( ) ;
@@ -437,7 +439,6 @@ export class TlAutoComplete extends ValueAccessorBase<any> implements OnChanges,
437
439
this . listenLoadData ( ) ;
438
440
this . handleModelCached ( ) ;
439
441
}
440
- this . loading = false ;
441
442
this . dataSource . setData ( value ) ;
442
443
this . setNotFound ( value . length === 0 ) ;
443
444
this . setFirstItemActive ( ) ;
@@ -452,9 +453,6 @@ export class TlAutoComplete extends ValueAccessorBase<any> implements OnChanges,
452
453
}
453
454
454
455
private listenLoadData ( ) {
455
- if ( ! this . dataSource ) {
456
- return ;
457
- }
458
456
this . subscription . add ( this . dataSource . loadMoreData . subscribe ( ( data : any ) => {
459
457
this . lazyLoad . emit ( { skip : data . skip , limit : data . limit , ...this . getFilters ( this . description ) } ) ;
460
458
} ) ) ;
0 commit comments