Skip to content

Commit dfccd65

Browse files
authored
fix: display default selected users and groups while disabling suggestions (#3279)
* display default selected users and groups * differentiate stories * fix tags
1 parent e685aee commit dfccd65

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.ts

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,39 @@ export class MgtPeoplePicker extends MgtTemplatedTaskComponent {
944944
const graph = provider.graph.forComponent(this);
945945

946946
if (!input.length) {
947+
if (
948+
(this.defaultSelectedUserIds.length > 0 || this.defaultSelectedGroupIds.length > 0) &&
949+
!this.selectedPeople.length &&
950+
!this.defaultSelectedUsers.length &&
951+
!this.defaultSelectedGroups.length
952+
) {
953+
this.defaultSelectedUsers = await getUsersForUserIds(
954+
graph,
955+
this.defaultSelectedUserIds,
956+
'',
957+
this.userFilters
958+
);
959+
this.defaultSelectedGroups = await getGroupsForGroupIds(
960+
graph,
961+
this.defaultSelectedGroupIds,
962+
this.peopleFilters
963+
);
964+
965+
this.defaultSelectedGroups = this.defaultSelectedGroups.filter(group => {
966+
return group !== null;
967+
});
968+
969+
this.defaultSelectedUsers = this.defaultSelectedUsers.filter(user => {
970+
return user !== null;
971+
});
972+
973+
this.selectedPeople = [...this.defaultSelectedUsers, ...this.defaultSelectedGroups];
974+
975+
if (this.hasMaxSelections) {
976+
this.disableTextInput();
977+
}
978+
this.requestUpdate();
979+
}
947980
if (this.disableSuggestions) {
948981
this._foundPeople = [];
949982
return;
@@ -1029,35 +1062,6 @@ export class MgtPeoplePicker extends MgtTemplatedTaskComponent {
10291062
}
10301063
}
10311064

1032-
if (
1033-
(this.defaultSelectedUserIds.length > 0 || this.defaultSelectedGroupIds.length > 0) &&
1034-
!this.selectedPeople.length &&
1035-
!this.defaultSelectedUsers.length &&
1036-
!this.defaultSelectedGroups.length
1037-
) {
1038-
this.defaultSelectedUsers = await getUsersForUserIds(graph, this.defaultSelectedUserIds, '', this.userFilters);
1039-
this.defaultSelectedGroups = await getGroupsForGroupIds(
1040-
graph,
1041-
this.defaultSelectedGroupIds,
1042-
this.peopleFilters
1043-
);
1044-
1045-
this.defaultSelectedGroups = this.defaultSelectedGroups.filter(group => {
1046-
return group !== null;
1047-
});
1048-
1049-
this.defaultSelectedUsers = this.defaultSelectedUsers.filter(user => {
1050-
return user !== null;
1051-
});
1052-
1053-
this.selectedPeople = [...this.defaultSelectedUsers, ...this.defaultSelectedGroups];
1054-
1055-
if (this.hasMaxSelections) {
1056-
this.disableTextInput();
1057-
}
1058-
this.requestUpdate();
1059-
}
1060-
10611065
if (input) {
10621066
people = [];
10631067

stories/components/peoplePicker/peoplePicker.properties.stories.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ closeModal.addEventListener('click', () => {
7979
`;
8080

8181
export const disableSuggestions = () => html`
82-
<mgt-people-picker disable-suggestions></mgt-people-picker>
82+
<h1>Disable suggestions</h1>
83+
<mgt-people-picker disable-suggestions></mgt-people-picker>
84+
<h1>Disable suggestions with default selected user Ids</h1>
85+
<mgt-people-picker
86+
default-selected-user-ids="e3d0513b-449e-4198-ba6f-bd97ae7cae85, 40079818-3808-4585-903b-02605f061225" disable-suggestions>
87+
</mgt-people-picker>
88+
89+
90+
8391
`;
8492

8593
export const dynamicGroupId = () => html`

0 commit comments

Comments
 (0)