refactor(grids): cleanup search snippets#5851
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the Grid search documentation snippets to reflect a refactored search API surface by switching from lastSearchInfo.matchInfoCache.length to lastSearchInfo.matchCount, and simplifying the sample templates accordingly.
Changes:
- Replace usage of
lastSearchInfo.matchInfoCache.lengthwithlastSearchInfo.matchCountin results-count snippets. - Remove the outer
*ngIf="@@igObjectRef.lastSearchInfo"wrapper in results display snippets (across EN/JP/KR docs).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| kr/components/grids_templates/search.md | Updates search result count snippets to use matchCount and adjusts template conditions. |
| jp/components/grids_templates/search.md | Updates search result count snippets to use matchCount and adjusts template conditions. |
| en/components/grids_templates/search.md | Updates search result count snippets to use matchCount and adjusts template conditions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <div class="resultsText"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchCount }} results | ||
| </span> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length == 0"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount == 0"> |
There was a problem hiding this comment.
The template now accesses @@igObjectRef.lastSearchInfo.matchCount without guarding lastSearchInfo. If lastSearchInfo is undefined before the first findNext/findPrev call, Angular will throw when evaluating the *ngIf expressions. Consider restoring the *ngIf="@@igObjectRef.lastSearchInfo" guard or using the safe-navigation operator (e.g., lastSearchInfo?.matchCount).
| <igx-suffix *ngIf="searchText.length > 0"> | ||
| <div class="resultsText" *ngIf="@@igObjectRef.lastSearchInfo"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchInfoCache.length }} results | ||
| <div class="resultsText"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchCount }} results | ||
| </span> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length == 0"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount == 0"> | ||
| No results |
There was a problem hiding this comment.
Inside the igx-suffix block, @@igObjectRef.lastSearchInfo.matchCount is used without guarding lastSearchInfo. If searchText is pre-populated (or findNext hasn’t run yet) this can still evaluate with lastSearchInfo undefined and cause a template error. Guard lastSearchInfo or use safe navigation.
| <div class="resultsText"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchCount }} results | ||
| </span> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length == 0"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount == 0"> |
There was a problem hiding this comment.
@@igObjectRef.lastSearchInfo.matchCount is referenced without checking lastSearchInfo first. If lastSearchInfo is undefined before the first search, Angular will throw when evaluating the *ngIf expressions. Consider adding back an *ngIf="@@igObjectRef.lastSearchInfo" guard or using safe navigation (lastSearchInfo?.matchCount).
| <igx-suffix *ngIf="searchText.length > 0"> | ||
| <div class="resultsText" *ngIf="@@igObjectRef.lastSearchInfo"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchInfoCache.length }} results | ||
| <div class="resultsText"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchCount }} results | ||
| </span> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length == 0"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount == 0"> | ||
| No results |
There was a problem hiding this comment.
In this snippet, @@igObjectRef.lastSearchInfo.matchCount is accessed without guarding lastSearchInfo. Even though the suffix is shown when searchText.length > 0, lastSearchInfo can still be undefined (e.g., when searchText is set programmatically before running findNext). Guard lastSearchInfo or use safe navigation.
| <div class="resultsText"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchCount }} results | ||
| </span> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length == 0"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount == 0"> |
There was a problem hiding this comment.
@@igObjectRef.lastSearchInfo.matchCount is used without guarding lastSearchInfo. If lastSearchInfo is undefined before the first findNext/findPrev call, Angular can throw while evaluating these *ngIf expressions. Consider restoring the *ngIf="@@igObjectRef.lastSearchInfo" guard or using safe navigation (lastSearchInfo?.matchCount).
| <igx-suffix *ngIf="searchText.length > 0"> | ||
| <div class="resultsText" *ngIf="@@igObjectRef.lastSearchInfo"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchInfoCache.length }} results | ||
| <div class="resultsText"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount > 0"> | ||
| {{ @@igObjectRef.lastSearchInfo.activeMatchIndex + 1 }} of {{ @@igObjectRef.lastSearchInfo.matchCount }} results | ||
| </span> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchInfoCache.length == 0"> | ||
| <span *ngIf="@@igObjectRef.lastSearchInfo.matchCount == 0"> | ||
| No results |
There was a problem hiding this comment.
Within the igx-suffix block, @@igObjectRef.lastSearchInfo.matchCount is accessed without guarding lastSearchInfo. If searchText is initialized programmatically and findNext hasn’t executed yet, this can still error. Guard lastSearchInfo or use safe navigation.
lastSearchInfo.matchInfoCache.length->lastSearchInfo.matchCountand removed the check for the entire object since that does nothingMatching samples PR IgniteUI/igniteui-angular-samples#3496
Checklist:
preview\beta../relative/path.mdIgxSelectComponent,<igx-combo>code blocksfor the names of classes / tags / propertiescode blockspending-localizationlabel when the review of the PR is done