microsoftgraph / microsoft-graph-toolkit

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

PeoplePicker: exclude userids #1821

Open ThomasPe opened 2 years ago

ThomasPe commented 2 years ago

Proposal: PeoplePicker userid not equals filter

Description

I would like to exclude certain users from a search query by user id.

Rationale

Currently it is not possible to exclude user ids from showing up in the results due to limitations in Microsoft Graph. However, there are scenarios where this makes sense from a UX perspective, eg. when a user was already selected previously and cannot be selected again.

Preferred Solution

While this is not possible directly through Microsoft Graph a "local" filter option might me a worthwhile workaround. Either by passing user ids directly or a filter function to the component that gets evaluated after the Graph response was received.

ghost commented 2 years ago

Hello ThomasPe, 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 🙌

musale commented 2 years ago

Hello @ThomasPe, thank you for this issue. It's true that a local filter option can be provided for this scenario. Are you also thinking of an option that not only allows user IDs but also other properties like emails, or display names? I think for your specific scenario, a property like exclude-userids would be sufficient. For the other properties maybe a stringified object with a key-value of propertyName-values. What do you think?

ThomasPe commented 2 years ago

Hi @musale, thanks for taking a look at this. I think user-id would be the most common scenario (show me users I don't already have added). Additional filters would be nice, but maybe passing a very generic filter function would be the most flexible and easy to maintain solution.

musale commented 1 year ago

@ThomasPe that's a good idea. We'll discuss it more internally and let you know the way forward.

sebastienlevert commented 1 year ago

Hello @ThomasPe. Can you expand a little bit more on this topic? I'm curious as today, the component will strip users already selected in the PeoplePicker. Is it that it would be selected "somewhere else", for instance a owner / members scenario where you wouldn't want a user to select a member that is already in the owners picker? This will help us! Thanks!

ThomasPe commented 1 year ago

Sure! I'm using the Picker to select users one by one as with perhaps 20+ people selected showing all will get too crowded imo. You can see how it works in this video around the 10s mark: https://www.zeitplan.io/videos/Zeitplan.io.mp4

sebastienlevert commented 1 year ago

Absolutely makes sense! This is a great example that definitely sells the use case! We'll discuss internally on the next steps and see how we can make them as close to the API as possible. Client-side filtering might be tricky for a list of users, so we'll have to keep that in mind! Thanks!

ThomasPe commented 1 year ago

appreciate the work you're all doing, thanks!

sebastienlevert commented 1 year ago

What we would suggest is to modify our code to do local filtering but taking into account the number of excluded ids to amend the number of items being returned and slice the X first that are not excluded.

Would you be willing to take a stab a send a PR? Thanks!