Skip to content

Commit fd86d38

Browse files
Fix for Issue 374
1 parent 843bec5 commit fd86d38

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/controls/peoplepicker/IPeoplePicker.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ export interface IPeoplePickerProps {
3737
* Maximum number of suggestions to show in the full suggestion list. (default: 5)
3838
*/
3939
suggestionsLimit?: number;
40+
/**
41+
* Specifies the minimum character count needed to begin retrieving search results. (default : 2)
42+
*/
43+
searchTextLimit?: number;
4044
/**
4145
* Specify the user / group types to retrieve
4246
*/

src/controls/peoplepicker/PeoplePickerComponent.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
2020
private peopleSearchService: SPPeopleSearchService;
2121
private suggestionsLimit: number;
2222
private groupId: number | string | (string | number)[];
23+
private searchTextCount: number;
2324

2425
constructor(props: IPeoplePickerProps) {
2526
super(props);
2627

2728
this.peopleSearchService = new SPPeopleSearchService(props.context);
2829
this.suggestionsLimit = this.props.suggestionsLimit ? this.props.suggestionsLimit : 5;
30+
this.searchTextCount = this.props.searchTextLimit ? this.props.searchTextLimit : 2;
2931

3032
telemetry.track('ReactPeoplePicker', {
3133
groupName: !!props.groupName,
@@ -135,7 +137,7 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
135137
* A search field change occured
136138
*/
137139
private onSearchFieldChanged = async (searchText: string, currentSelected: IPersonaProps[]): Promise<IPersonaProps[]> => {
138-
if (searchText.length > 2) {
140+
if (searchText.length > this.searchTextCount) {
139141
const results = await this.peopleSearchService.searchPeople(searchText, this.suggestionsLimit, this.props.principalTypes, this.props.webAbsoluteUrl, this.groupId, this.props.ensureUser, this.props.allowUnvalidated);
140142
// Remove duplicates
141143
const { selectedPersons, mostRecentlyUsedPersons } = this.state;

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
15551555
<PeoplePicker context={this.props.context}
15561556
titleText="People Picker (tenant scoped)"
15571557
personSelectionLimit={10}
1558+
searchTextLimit={5} //New property : Specifies the minimum character count needed to begin retrieving search results. (default : 2)
15581559
// groupName={"Team Site Owners"}
15591560
showtooltip={true}
15601561
required={true}

0 commit comments

Comments
 (0)