@@ -46,7 +46,7 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
46
46
* componentWillMount lifecycle hook
47
47
*/
48
48
public componentWillMount ( ) : void {
49
- this . getInitialPersons ( ) ;
49
+ this . getInitialPersons ( this . props ) ;
50
50
}
51
51
52
52
@@ -56,20 +56,21 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
56
56
public componentWillUpdate ( nextProps : IPeoplePickerProps , nextState : IPeoplePickerState ) : void {
57
57
if ( ! isEqual ( this . props . defaultSelectedUsers , nextProps . defaultSelectedUsers ) ||
58
58
this . props . groupName !== nextProps . groupName ||
59
- this . props . webAbsoluteUrl !== nextProps . webAbsoluteUrl ) {
60
- this . getInitialPersons ( ) ;
59
+ this . props . webAbsoluteUrl !== nextProps . webAbsoluteUrl ||
60
+ this . peopleSearchService . getSumOfPrincipalTypes ( this . props . principalTypes ) !== this . peopleSearchService . getSumOfPrincipalTypes ( nextProps . principalTypes ) ) {
61
+ this . getInitialPersons ( nextProps ) ;
61
62
}
62
63
}
63
64
64
65
65
66
/**
66
67
* Get initial persons
67
68
*/
68
- private async getInitialPersons ( ) {
69
- const { groupName } = this . props ;
69
+ private async getInitialPersons ( props : IPeoplePickerProps ) {
70
+ const { groupName } = props ;
70
71
// Check if a group property was provided, and get the group ID
71
72
if ( groupName ) {
72
- this . groupId = await this . peopleSearchService . getGroupId ( this . props . groupName , this . props . webAbsoluteUrl ) ;
73
+ this . groupId = await this . peopleSearchService . getGroupId ( props . groupName , props . webAbsoluteUrl ) ;
73
74
if ( ! this . groupId ) {
74
75
this . setState ( {
75
76
errorMessage : "Group could not be found."
@@ -81,10 +82,10 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
81
82
}
82
83
83
84
// Check for default user values
84
- if ( this . props . defaultSelectedUsers && this . props . defaultSelectedUsers . length ) {
85
+ if ( props . defaultSelectedUsers ) {
85
86
let selectedPersons : IPersonaProps [ ] = [ ] ;
86
- for ( const userValue of this . props . defaultSelectedUsers ) {
87
- const userResult = await this . peopleSearchService . searchPersonByEmailOrLogin ( userValue , this . props . principalTypes , this . props . webAbsoluteUrl , this . groupId , this . props . ensureUser ) ;
87
+ for ( const userValue of props . defaultSelectedUsers ) {
88
+ const userResult = await this . peopleSearchService . searchPersonByEmailOrLogin ( userValue , props . principalTypes , props . webAbsoluteUrl , this . groupId , props . ensureUser ) ;
88
89
if ( userResult ) {
89
90
selectedPersons . push ( userResult ) ;
90
91
}
0 commit comments