Skip to content

Commit 5fd8284

Browse files
committed
2 parents e1dc03d + 696f9d7 commit 5fd8284

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

docs/documentation/docs/controls/PeoplePicker.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ The People picker control can be configured with the following properties:
7070
| onChange | (items: IPersonaProps[]) => void | no | Get the selected users in the control. | |
7171
| peoplePickerWPclassName | string | no | applies custom styling to the people picker element | |
7272
| peoplePickerCntrlclassName | string | no | applies custom styling to the people picker control only | |
73-
| defaultSelectedUsers | string[] | no | Default selected user emails or login names or user title`|inactive`. User title is just to display the inactive users. Append the user title with string `|inactive` in lower case. | |
73+
| defaultSelectedUsers | string[] | no | Default selected user emails or login names, optionally append `/title` with forward slash.
74+
If user is not found then only optional title will be shown. If you do not have email or login name of inactive users just pass `/title` alone prefixed with slash.| |
7475
| webAbsoluteUrl | string | no | Specify the site URL on which you want to perform the user query call. If not provided, the people picker will perform a tenant wide people/group search. When provided it will search users/groups on the provided site. | |
7576
| principalTypes | PrincipalType[] | no | Define which type of data you want to retrieve: User, SharePoint groups, Security groups. Multiple are possible. | |
7677
| ensureUser | boolean | no | When ensure user property is true, it will return the local user ID on the current site when doing a tenant wide search. | false |

src/controls/peoplepicker/PeoplePickerComponent.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,17 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
9393
if (defaultSelectedUsers) {
9494
let selectedPersons: IPersonaProps[] = [];
9595
for (const userValue of props.defaultSelectedUsers) {
96-
if (userValue.endsWith("|inactive")) {
97-
const temp: string = userValue.slice(0, -9);
98-
if (temp) {
99-
const inactiveUser: IPersonaProps = { text: temp };
100-
selectedPersons.push(inactiveUser);
101-
}
96+
let valueAndTitle: string[] = [];
97+
valueAndTitle.push(userValue);
98+
if (userValue && userValue.indexOf('/') > -1)
99+
valueAndTitle = userValue.split('/');
100+
const userResult = await this.peopleSearchService.searchPersonByEmailOrLogin(valueAndTitle[0], principalTypes, webAbsoluteUrl, this.groupId, ensureUser);
101+
if (userResult) {
102+
selectedPersons.push(userResult);
102103
}
103-
else {
104-
const userResult = await this.peopleSearchService.searchPersonByEmailOrLogin(userValue, principalTypes, webAbsoluteUrl, this.groupId, ensureUser);
105-
if (userResult) {
106-
selectedPersons.push(userResult);
107-
}
104+
else if (valueAndTitle.length == 2 && valueAndTitle[1]) { //user not found.. bind the title if exists
105+
const inactiveUser: IPersonaProps = { text: valueAndTitle[1] };
106+
selectedPersons.push(inactiveUser);
108107
}
109108
}
110109

0 commit comments

Comments
 (0)