pnp / sp-dev-fx-controls-react

Reusable React controls for SPFx solutions
https://pnp.github.io/sp-dev-fx-controls-react/
MIT License
383 stars 380 forks source link

PeoplePicker Does not throw error when invalid user is bound #1010

Open Ashwini-Blore opened 3 years ago

Ashwini-Blore commented 3 years ago

Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your needs please complete the below template to ensure we have the details to help. Thanks!

Please check out the documentation to see if your question is already addressed there. This will help us ensure our documentation is up to date.

Category

[ ] Enhancement

[ X] Bug

[ ] Question

Version

Please specify what version of the library you are using: [ 3.3.0 ]

Expected / Desired Behavior / Question

If an invalid user is bound to people picker, error must be captured or shown in some manner so that users can update the invalid user with active user

Observed Behavior

When used in conjunction with sharepoint, the list/people column may hold inactive user. When such user is bound to attribute defaultSelectedUsers, then picker will load empty, without indicating any error on UI.

Steps to Reproduce

<PeoplePicker context={context} defaultSelectedUsers={["OrphanUser"]} personSelectionLimit={1} showtooltip={false} required={true} disabled={false} ensureUser={true} onGetErrorMessage={(items) => { var item = items[0]; if(item.Email !=null) return undefined; else return 'Invalid Items' }}
onChange={ (items) => { //Set State here } } showHiddenInUI={false} principalTypes={[PrincipalType.User]} resolveDelay={1000} />

In the above sample code, the getErrorMessage works great, in conjunction with OnChange. But it is not triggered on component mount or initialized. Hence users will not understand why the picker is empty, when form loads. In scenarios such as ,people leave organisation and data needs to be updated with new user, we need a UI display which says that input bound to the control is invalid, so that new user can be updated..

Submission Guidelines

Currently, people picker control is not resolving the invalid user, by validating user object within. The outcome of that validation needs to be exposed & made available for display. Either new attribute/function needs to be exposed or onGetErrorMessage needs to be run everytime the PeoplePicker mounted + changed.

Thanks!

ghost commented 3 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

joelfmrodrigues commented 1 year ago

@Ashwini-Blore many thanks for reporting this issue and really sorry for the long delay. Could you please confirm if this still happens with the latest version, and if so, would you be able to help fix it and submit a pull request?

michaelmaillot commented 1 year ago

Hi everyone,

I confirm that there's nothing in the control mounting that handles error when selected users are not found. Only works with not found groups.