Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UI freezing while searching for users #145

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 4 additions & 0 deletions src/controls/peoplepicker/IPeoplePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export interface IPeoplePickerProps {
* Name of SharePoint Group
*/
groupName?: string;
/**
* Limit the number of suggestions show to user (default: 5)
*/
suggestionLimit?: number;
/**
* Selection Limit of Control
*/
Expand Down
24 changes: 19 additions & 5 deletions src/controls/peoplepicker/PeoplePickerComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,25 @@ export class PeoplePicker extends React.Component<IPeoplePickerProps, IPeoplePic
* @param filterText
*/
private _filterPersons(filterText: string): IPersonaProps[] {
return this.state.peoplePersonaMenu.filter(item =>
this._doesTextStartWith(item.text as string, filterText)
|| this._doesTextContains(item.text as string, filterText)
|| this._doesTextStartWith(item.secondaryText as string, filterText)
|| this._doesTextContains(item.secondaryText as string, filterText));
let result: IPersonaProps[] = [];
let suggestionLimit = this.props.suggestionLimit ? this.props.suggestionLimit : 5;

for (let i: number = 0; i < this.state.peoplePersonaMenu.length; i++) {
let item = this.state.peoplePersonaMenu[i];

if (this._doesTextStartWith(item.text as string, filterText)
|| this._doesTextContains(item.text as string, filterText)
|| this._doesTextStartWith(item.secondaryText as string, filterText)
|| this._doesTextContains(item.secondaryText as string, filterText))
{
result.push(item);
if (result.length === suggestionLimit) {
break;
}
}
}

return result;
}


Expand Down