Skip to content

Commit 7ff1fcd

Browse files
Sankar KumarSankar Kumar
authored andcommitted
Extended defaultSelectedUsers property to show inactive users
1 parent b6b3dbe commit 7ff1fcd

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

docs/documentation/docs/controls/PeoplePicker.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ 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 | |
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. | |
7474
| 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. | |
7575
| principalTypes | PrincipalType[] | no | Define which type of data you want to retrieve: User, SharePoint groups, Security groups. Multiple are possible. | |
7676
| 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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,18 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
9393
if (defaultSelectedUsers) {
9494
let selectedPersons: IPersonaProps[] = [];
9595
for (const userValue of props.defaultSelectedUsers) {
96-
const userResult = await this.peopleSearchService.searchPersonByEmailOrLogin(userValue, principalTypes, webAbsoluteUrl, this.groupId, ensureUser);
97-
if (userResult) {
98-
selectedPersons.push(userResult);
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+
}
102+
}
103+
else {
104+
const userResult = await this.peopleSearchService.searchPersonByEmailOrLogin(userValue, principalTypes, webAbsoluteUrl, this.groupId, ensureUser);
105+
if (userResult) {
106+
selectedPersons.push(userResult);
107+
}
99108
}
100109
}
101110

0 commit comments

Comments
 (0)