@@ -108,12 +108,13 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
108108 @property ( {
109109 attribute : 'type' ,
110110 converter : ( value , type ) => {
111+ value = value . toLowerCase ( ) ;
111112 if ( ! value || value . length === 0 ) {
112- return PersonType . Any ;
113+ return PersonType . any ;
113114 }
114115
115116 if ( typeof PersonType [ value ] === 'undefined' ) {
116- return PersonType . Any ;
117+ return PersonType . any ;
117118 } else {
118119 return PersonType [ value ] ;
119120 }
@@ -140,7 +141,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
140141 attribute : 'group-type' ,
141142 converter : ( value , type ) => {
142143 if ( ! value || value . length === 0 ) {
143- return GroupType . Any ;
144+ return GroupType . any ;
144145 }
145146
146147 const values = value . split ( ',' ) ;
@@ -154,7 +155,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
154155 }
155156
156157 if ( groupTypes . length === 0 ) {
157- return GroupType . Any ;
158+ return GroupType . any ;
158159 }
159160
160161 // tslint:disable-next-line:no-bitwise
@@ -255,8 +256,8 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
255256 @property ( { attribute : false } ) private _showLoading : boolean ;
256257
257258 private _groupId : string ;
258- private _type : PersonType = PersonType . Person ;
259- private _groupType : GroupType = GroupType . Any ;
259+ private _type : PersonType = PersonType . person ;
260+ private _groupType : GroupType = GroupType . any ;
260261
261262 private defaultPeople : IDynamicPerson [ ] ;
262263
@@ -645,12 +646,25 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
645646 if ( ! people && provider && provider . state === ProviderState . SignedIn ) {
646647 const graph = provider . graph . forComponent ( this ) ;
647648
648- // default common people
649649 if ( ! input . length && this . _isFocused ) {
650650 if ( this . defaultPeople ) {
651651 people = this . defaultPeople ;
652652 } else {
653- people = await getPeople ( graph ) ;
653+ if ( this . groupId ) {
654+ if ( this . _groupPeople === null ) {
655+ try {
656+ this . _groupPeople = await getPeopleFromGroup ( graph , this . groupId ) ;
657+ } catch ( _ ) {
658+ this . _groupPeople = [ ] ;
659+ }
660+ }
661+ people = this . _groupPeople || [ ] ;
662+ } else if ( this . type === PersonType . person || this . type === PersonType . any ) {
663+ people = await getPeople ( graph ) ;
664+ } else if ( this . type === PersonType . group ) {
665+ const groups = ( await findGroups ( graph , '' , this . showMax , this . groupType ) ) || [ ] ;
666+ people = groups ;
667+ }
654668 this . defaultPeople = people ;
655669 }
656670 this . _showLoading = false ;
@@ -664,19 +678,9 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
664678 this . fireCustomEvent ( 'selectionChanged' , this . selectedPeople ) ;
665679 }
666680
667- if ( this . groupId && input ) {
668- if ( this . _groupPeople === null ) {
669- try {
670- this . _groupPeople = await getPeopleFromGroup ( graph , this . groupId ) ;
671- } catch ( _ ) {
672- this . _groupPeople = [ ] ;
673- }
674- }
675-
676- people = this . _groupPeople || [ ] ;
677- } else if ( input ) {
681+ if ( input ) {
678682 people = [ ] ;
679- if ( this . type === PersonType . Person || this . type === PersonType . Any ) {
683+ if ( this . type === PersonType . person || this . type === PersonType . any ) {
680684 try {
681685 people = ( await findPeople ( graph , input , this . showMax ) ) || [ ] ;
682686 } catch ( e ) {
@@ -700,7 +704,8 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
700704 }
701705 }
702706
703- if ( ( this . type === PersonType . Group || this . type === PersonType . Any ) && people . length < this . showMax ) {
707+ if ( ( this . type === PersonType . group || this . type === PersonType . any ) && people . length < this . showMax ) {
708+ people = [ ] ;
704709 try {
705710 const groups = ( await findGroups ( graph , input , this . showMax , this . groupType ) ) || [ ] ;
706711 people = people . concat ( groups ) ;
@@ -863,6 +868,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
863868 this . userInput = '' ;
864869 // remove last person in selected list
865870 this . selectedPeople = this . selectedPeople . splice ( 0 , this . selectedPeople . length - 1 ) ;
871+ this . loadState ( ) ;
866872 // reset flyout position
867873 this . hideFlyout ( ) ;
868874 this . showFlyout ( ) ;
@@ -888,7 +894,6 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
888894 * @param input - input text
889895 */
890896 private handleUserSearch ( input : HTMLInputElement ) {
891- this . _showLoading = true ;
892897 if ( ! this . _debouncedSearch ) {
893898 this . _debouncedSearch = debounce ( async ( ) => {
894899 // Wait a few milliseconds before showing the flyout.
@@ -911,6 +916,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
911916 }
912917
913918 if ( this . userInput !== input . value ) {
919+ this . _showLoading = true ;
914920 this . userInput = input . value ;
915921 this . _debouncedSearch ( ) ;
916922 }
0 commit comments