The documentation allows you to enter any string, hit [Tab] and it will display it as a persona. Trying to replicate this behavior, but am having trouble and the sample code says nothing.
https://developer.microsoft.com/en-us/fabric#/components/peoplepicker
My PeoplePicker:
<CompactPeoplePicker
getTextFromItem={(item) => { return item.text; } }
onItemSelected={(item) => {
console.log(item);
return new Promise((resolve, reject) => {
resolve(item);
})
}}
selectedItems={this.state.currentSelectedItems}
onChange={(items) => {
console.log(items);
this.setState({ currentSelectedItems: items});
}}
onResolveSuggestions={this._onResolveSuggestions}
className={'ms-PeoplePicker'}
pickerSuggestionsProps={{
suggestionsHeaderText: 'Suggested People',
mostRecentlyUsedHeaderText: 'Suggested Contacts',
noResultsFoundText: 'No results found',
loadingText: 'Loading',
showRemoveButtons: true,
suggestionsAvailableAlertText: 'People Picker Suggestions available',
suggestionsContainerAriaLabel: 'Suggested contacts'
}}
/>
The answer is to simply return a new Persona
as part of onResolveSuggestions
_onResolveSuggestions = (filterText, ...) => {
var suggestions = ...;
suggestions.splice(0, 0, { name: filterText, text: filterText });
return suggestions;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.