pnp / pnp/sp-dev-fx-controls-react

How can I clear the selected Persons in the PeoplePicker component?

Open
#1,320 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:question
Dominant language
TypeScript
Stars
433
Forks
418
Avg merge
5d 6m
Merged PRs (30d)
19

Description

Category

[ ] Enhancement

[ ] Bug

[x] Question

Version

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

I can not upgrade to the latest version 3.10.0, because in that version the PeoplePicker is broken. See: https://github.com/pnp/sp-dev-fx-controls-react/issues/1292

Question

How can I clear the selected Persons in the PeoplePicker component?

I found a solution, that works. By creating a ref to the PeoplePicker and then doing.
peoplePickerRef.current.setState({ ...peoplePickerRef.current.state, selectedPersons: [] });

However, I read that state should only be updated by the component itself, and props should only be updated by other components. So setting the state from another component does not seem to be a good way to go.

It seems that there used to be a prop selectedPersons on the PeoplePicker, which I could use to solve this Problem. But in my version this does not work, as typescript is complaining, that this prop does not exist on the PeoplePicker component.

Any hints are appreciated, like was this prop really removed? Is there a new way to handle clearing the selected Persons?

Thanks for any help in advance!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the PeoplePicker public API and the selected-person handling described in the issue for versions 3.9.0 and 3.10.0. Confirm whether a supported clearing mechanism exists and define the expected behavior before making any change; the payload names no source file or test to run.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.