@@ -76,12 +76,14 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
7676 // User input in search
7777 @property ( ) private _userInput : string = '' ;
7878
79+ // if search is still loading don't load "people not found" state
80+ @property ( ) private showLoading = false ;
81+ @property ( ) private isLoading = false ;
82+
7983 // tracking of user arrow key input for selection
8084 private arrowSelectionCount : number = 0 ;
8185 // List of people requested if group property is provided
8286 private groupPeople : any [ ] ;
83- // if search is still loading don't load "people not found" state
84- private isLoading = false ;
8587 private debouncedSearch ;
8688
8789 constructor ( ) {
@@ -320,13 +322,10 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
320322 let people : any ;
321323
322324 if ( provider && provider . state === ProviderState . SignedIn ) {
323- const that = this ;
324- let loading = true ;
325+ this . isLoading = true ;
325326
326327 setTimeout ( ( ) => {
327- if ( loading ) {
328- that . isLoading = true ;
329- }
328+ this . showLoading = this . isLoading ;
330329 } , 400 ) ;
331330
332331 const client = Providers . globalProvider . graph ;
@@ -345,8 +344,8 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
345344 }
346345
347346 this . people = this . filterPeople ( people ) ;
348- loading = false ;
349347 this . isLoading = false ;
348+ this . showLoading = false ;
350349 }
351350 } else {
352351 this . people = [ ] ;
@@ -508,12 +507,12 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
508507 let people : any = this . people ;
509508 let content : TemplateResult ;
510509
511- if ( people ) {
510+ if ( this . showLoading ) {
511+ content = this . renderTemplate ( 'loading' , null , 'loading' ) || this . renderLoadingMessage ( ) ;
512+ } else if ( people ) {
512513 people = people . slice ( 0 , this . showMax ) ;
513514
514- if ( this . isLoading ) {
515- content = this . renderTemplate ( 'loading' , null , 'loading' ) || this . renderLoadingMessage ( ) ;
516- } else if ( people . length === 0 && this . _userInput . length > 0 ) {
515+ if ( ! this . isLoading && people . length === 0 && this . _userInput . length > 0 ) {
517516 content = this . renderTemplate ( 'error' , null , 'error' ) || this . renderErrorMessage ( ) ;
518517 } else {
519518 if ( people [ 0 ] ) {
0 commit comments