pnp / pnp/sp-dev-fx-controls-react
PeoplePicker Does not throw error when invalid user is bound
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 433
- Forks
- 418
- Avg merge
- 5d 6m
- Merged PRs (30d)
- 19
Description
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!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the PeoplePicker component and its handling of defaultSelectedUsers, onGetErrorMessage, and component initialization. Reproduce the invalid "OrphanUser" case from the issue, then trace why validation runs on change but not mount. Done means an invalid bound user produces a visible or otherwise exposed error when the picker is initialized, while existing change validation remains working.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100