Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Co-authored-by: OlgaLarina <[email protected]>
  • Loading branch information
OlgaLarina and OlgaLarina authored Jan 19, 2024
1 parent b4bb731 commit 13a2369
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/survey-creator-core/src/property-grid/search-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ export class SearchManager extends Base {
newValueInLow = newValueInLow.toLocaleLowerCase().trim();
const visibleQuestions = this.survey.getAllQuestions().filter(q => q.isVisible);
return visibleQuestions.filter(q => {
let questionTitle = q.title;
if(!!questionTitle) {
questionTitle = normalize(questionTitle, "search");
questionTitle = questionTitle.toLocaleLowerCase().trim();
let srcString = q.name + "|" + q.title + "|" + q.description;
if(!!srcString) {
srcString = normalize(srcString, "search");
srcString = srcString.toLocaleLowerCase().trim();
}
return questionTitle.indexOf(newValueInLow) !== -1;
return srcString.indexOf(newValueInLow) !== -1;
});
}
private setFiterString(newValue: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,39 @@ test("SearchManager: normalizeTextCallback", () => {
expect(searchManager.allMatches).toHaveLength(2);

settings.comparator.normalizeTextCallback = (str: string, reason: string): string => { return str; };
});

test("SearchManager: search by name and description", () => {
const searchManager = new SearchManager();
const survey = new SurveyModel({
"elements": [
{
"type": "text",
"name": "q1",
"title": "First",
"description": "First description"
},
{
"type": "text",
"name": "q2",
"title": "Second",
"description": "Second description"
},
{
"type": "text",
"name": "q3",
"title": "Last",
"description": "Last description"
}
]
});
searchManager.setSurvey(survey);
searchManager.filterString = "First";
expect(searchManager.allMatches).toHaveLength(1);

searchManager.filterString = "q1";
expect(searchManager.allMatches).toHaveLength(1);

searchManager.filterString = "description";
expect(searchManager.allMatches).toHaveLength(3);
});

0 comments on commit 13a2369

Please sign in to comment.