microsoftgraph / microsoft-graph-toolkit

Authentication Providers and UI components for Microsoft Graph 🦒
https://docs.microsoft.com/graph/toolkit/overview
Other
939 stars 298 forks source link

[BUG] Using defaultSelectedUserIds and disableSuggestions people-picker component does not render the default selected users #3201

Closed eduardpaul closed 4 weeks ago

eduardpaul commented 3 months ago

Describe the bug

If both parameters are used (defaultSelectedUserIds and disableSuggestions) on the initial load, the component does not show the default selected users. If you try to add a new one, all the default are rendered fine.

We think that the return in the following code, should be removed to solve this issue or the conditional statement moved below the rendering logic: https://github.com/microsoftgraph/microsoft-graph-toolkit/blob/43ebacf3304bbe2bbdd537ea04dab227d4d52103/packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.ts#L945C1-L945C18

To Reproduce Steps to reproduce the behavior: add people picker with defaultSelectedUserIds and disableSuggestions.

Expected behavior On initial load, default selected users should be shown. After that, disable suggestions.

Environment (please complete the following information): N/A

Additional context Add any other context about the problem here.

musale commented 3 months ago

@eduardpaul thank you for raising this issue. The idea behind disableSuggestions was to show no people suggestions when you click inside the people-picker input https://github.com/microsoftgraph/microsoft-graph-toolkit/pull/3048. Then, you can start typing and the suggestions come in. In the shown lines, the return is used to stop an unnecessary graph call below those lines. Using both defaultSelectedUserIds means we can add logic that sets the user ids to the people variable in that block and still maintain the intention not to make an unnecessary call. Is this something you would like to help contribute?

eduardpaul commented 4 weeks ago

Thanks a lot @musale ! Did not find time to try to do this by myself 😅😅