[BUG] mgt-people-picker default values are ignored
Describe the bug When using the mgt-people-picker React component in a SPFx ListViewCommandSet with Dialog, the defaultSelectedUserIds and defaultSelectedGroupIds are not shown. Following Code produces the issue:
return (
<div>
<PeoplePicker
selectionMode='multiple'
defaultSelectedUserIds={[
'9006559d-397a-4cb4-80e1-0548141c0be0',
]}></PeoplePicker>
</div>
);
The default Id provided is a valid Id of a user (checked in Azure AD and logged the value when selecting in control).
To Reproduce Steps to reproduce the behavior:
- Launch the SPFx extension locally
- Navigate to a library and open the ListViewCommandSet
- Dialog should open with mgt-people-picker and no default values selected
Expected behavior The default values should be in the selection of the mgt-people-picker React component.
Environment (please complete the following information):
- OS: [e.g. iOS]
- Browser: Chrome
- Framework: React
- Context SharePoint Online
- Version MGT v3
- Provider SharePointProvider
Hello FreakIsTea, thank you for opening an issue with us!
I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌
@FreakIsTea thanks for raising this Looks like it's also a problem with the attribute used to pass the default selection in too https://mgt.dev/?path=/story/components-mgt-people-picker-properties--picker-default-selected-user-ids
Adding some notes as I investigate here: Testing with 2.11.2 via mgt loader from unpkg shows the correct behavior We can see the changes between the two with versions with the below diff:
git difftool 4dac3bad74d8f08b6d5e2cf1caea4648e3a352cd e3848833279af57920fc7855d9da557e3f145df8 ./packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.ts
We failed to update a check to look at length after ensuring that the default value selection arrays were initialized to an empty array at object creation :?
Hi @gavinbarron Thanks for the quick response! Will this also fix the components in the mgt-react library for spfx components? I'm not quite sure how the mgt package structure works.
Yes, the react library is a thin binding and typing wrapper around the underlying web components.