microsoft-graph-toolkit icon indicating copy to clipboard operation
microsoft-graph-toolkit copied to clipboard

[BUG] mgt-people-picker default values are ignored

Open FreakIsTea opened this issue 3 years ago • 6 comments

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:

  1. Launch the SPFx extension locally
  2. Navigate to a library and open the ListViewCommandSet
  3. 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

FreakIsTea avatar Jun 29 '23 14:06 FreakIsTea

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 🙌

ghost avatar Jun 29 '23 14:06 ghost

@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

gavinbarron avatar Jun 29 '23 18:06 gavinbarron

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

gavinbarron avatar Jun 29 '23 22:06 gavinbarron

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 :?

gavinbarron avatar Jun 29 '23 22:06 gavinbarron

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.

FreakIsTea avatar Jun 30 '23 07:06 FreakIsTea

Yes, the react library is a thin binding and typing wrapper around the underlying web components.

gavinbarron avatar Jun 30 '23 15:06 gavinbarron