3

I want to set default selected Item on people picker?

<NormalPeoplePicker
        defaultSelectedItems={()}
        inputProps={{ disabled: true }}
        onChange={this._onChangePeoplePicker}
        onResolveSuggestions={this._onFilterChangedPeoplePicker}
        getTextFromItem={(persona: IPersonaProps) => persona.primaryText}
        pickerSuggestionsProps={suggestionProps}
        className={'ms-PeoplePicker'}
        key={'normal'} />
</div>

How to use defaultSelectedItems --> https://developer.microsoft.com/en-us/fabric#/components/peoplepicker ?

1 Answer 1

3

I have found that earlier versions lacked the selected items property but the current version, 5.28.0, includes the selected items property and with that I was able to set the default select. I didn't have any luck getting the default selected items to work unless I had the value the first time the component was rendered. If I passed a default and then based off of SP REST calls changed the state the component would update. Here is an example of what I am now using that works.

<CompactPeoplePicker selectedItems={this.props.selectedItems} />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.