From fd86d3854014631ec6cec4386824f7a3f6d58532 Mon Sep 17 00:00:00 2001 From: Nishkalank Bezawada <47456098+NishkalankBezawada@users.noreply.github.com> Date: Fri, 29 Sep 2023 14:30:14 +0200 Subject: [PATCH 1/2] Fix for Issue 374 --- src/controls/peoplepicker/IPeoplePicker.ts | 4 ++++ src/controls/peoplepicker/PeoplePickerComponent.tsx | 4 +++- src/webparts/controlsTest/components/ControlsTest.tsx | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controls/peoplepicker/IPeoplePicker.ts b/src/controls/peoplepicker/IPeoplePicker.ts index a77a65bfa..763ef9c98 100644 --- a/src/controls/peoplepicker/IPeoplePicker.ts +++ b/src/controls/peoplepicker/IPeoplePicker.ts @@ -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 */ diff --git a/src/controls/peoplepicker/PeoplePickerComponent.tsx b/src/controls/peoplepicker/PeoplePickerComponent.tsx index c1746b907..f4317a2b3 100644 --- a/src/controls/peoplepicker/PeoplePickerComponent.tsx +++ b/src/controls/peoplepicker/PeoplePickerComponent.tsx @@ -20,12 +20,14 @@ export class PeoplePicker extends React.Component => { - 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; diff --git a/src/webparts/controlsTest/components/ControlsTest.tsx b/src/webparts/controlsTest/components/ControlsTest.tsx index 356611fcb..207ba5642 100644 --- a/src/webparts/controlsTest/components/ControlsTest.tsx +++ b/src/webparts/controlsTest/components/ControlsTest.tsx @@ -1555,6 +1555,7 @@ export default class ControlsTest extends React.Component Date: Fri, 29 Sep 2023 15:18:24 +0200 Subject: [PATCH 2/2] Updated People picker documentation --- docs/documentation/docs/controls/PeoplePicker.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/documentation/docs/controls/PeoplePicker.md b/docs/documentation/docs/controls/PeoplePicker.md index a44412c66..ab8f623ba 100644 --- a/docs/documentation/docs/controls/PeoplePicker.md +++ b/docs/documentation/docs/controls/PeoplePicker.md @@ -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]} @@ -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 | no | Styles to apply on control | +| searchTextLimit | number | no | Specifies the minimum character count needed to begin retrieving search results. | 2 | Enum `PrincipalType`