Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/documentation/docs/controls/PeoplePicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { PeoplePicker, PrincipalType } from "@pnp/spfx-controls-react/lib/People
showtooltip={true}
required={true}
disabled={true}
searchTextLimit={5}
onChange={this._getPeoplePickerItems}
showHiddenInUI={false}
principalTypes={[PrincipalType.User]}
Expand Down Expand Up @@ -83,6 +84,7 @@ The People picker control can be configured with the following properties:
| resolveDelay | number | no | Add delay to resolve and search users | 200 |
| placeholder | string | no | Short text hint to display in empty picker |
| styles | Partial<IBasePickerStyles> | no | Styles to apply on control |
| searchTextLimit | number | no | Specifies the minimum character count needed to begin retrieving search results. | 2 |

Enum `PrincipalType`

Expand Down
4 changes: 4 additions & 0 deletions src/controls/peoplepicker/IPeoplePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export interface IPeoplePickerProps {
* Maximum number of suggestions to show in the full suggestion list. (default: 5)
*/
suggestionsLimit?: number;
/**
* Specifies the minimum character count needed to begin retrieving search results. (default : 2)
*/
searchTextLimit?: number;
/**
* Specify the user / group types to retrieve
*/
Expand Down
4 changes: 3 additions & 1 deletion src/controls/peoplepicker/PeoplePickerComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
private peopleSearchService: SPPeopleSearchService;
private suggestionsLimit: number;
private groupId: number | string | (string | number)[];
private searchTextCount: number;

constructor(props: IPeoplePickerProps) {
super(props);

this.peopleSearchService = new SPPeopleSearchService(props.context);
this.suggestionsLimit = this.props.suggestionsLimit ? this.props.suggestionsLimit : 5;
this.searchTextCount = this.props.searchTextLimit ? this.props.searchTextLimit : 2;

telemetry.track('ReactPeoplePicker', {
groupName: !!props.groupName,
Expand Down Expand Up @@ -135,7 +137,7 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
* A search field change occured
*/
private onSearchFieldChanged = async (searchText: string, currentSelected: IPersonaProps[]): Promise<IPersonaProps[]> => {
if (searchText.length > 2) {
if (searchText.length > this.searchTextCount) {
const results = await this.peopleSearchService.searchPeople(searchText, this.suggestionsLimit, this.props.principalTypes, this.props.webAbsoluteUrl, this.groupId, this.props.ensureUser, this.props.allowUnvalidated);
// Remove duplicates
const { selectedPersons, mostRecentlyUsedPersons } = this.state;
Expand Down
1 change: 1 addition & 0 deletions src/webparts/controlsTest/components/ControlsTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1555,6 +1555,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
<PeoplePicker context={this.props.context}
titleText="People Picker (tenant scoped)"
personSelectionLimit={10}
searchTextLimit={5} //New property : Specifies the minimum character count needed to begin retrieving search results. (default : 2)
// groupName={"Team Site Owners"}
showtooltip={true}
required={true}
Expand Down