Skip to content

Commit ba6d738

Browse files
MKirovaMayaKirova
authored andcommitted
chore(*): Applying more perfomant way to find last index.
1 parent ed57033 commit ba6d738

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

projects/igniteui-angular/src/lib/grids/grid-navigation.service.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class IgxGridNavigationService {
243243
const verticalScroll = this.grid.verticalScrollContainer.getScroll();
244244
const cellSelector = this.getCellSelector(visibleColumnIndex);
245245
const targetScr = this.grid.verticalScrollContainer.getScrollForIndex(targetIndex, false);
246-
if (verticalScroll.scrollTop === targetScr) {
246+
if (targetScr >= verticalScroll.scrollTop) {
247247
const cells = this.grid.nativeElement.querySelectorAll(
248248
`${cellSelector}[data-visibleIndex="${visibleColumnIndex}"]`);
249249
(cells[0] as HTMLElement).focus();
@@ -265,10 +265,13 @@ export class IgxGridNavigationService {
265265
}
266266

267267
private findLastDataRowIndex() {
268-
const dv = this.grid.dataView;
269-
const reversedData = dv.slice().reverse();
270-
const record = reversedData.find(rec => !this.grid.isGroupByRecord(rec));
271-
return dv.indexOf(record);
268+
let i = this.grid.dataView.length;
269+
while (i--) {
270+
const rec = this.grid.dataView[i];
271+
if (!this.grid.isGroupByRecord(rec)) {
272+
return i;
273+
}
274+
}
272275
}
273276

274277
public navigateBottom(visibleColumnIndex) {

0 commit comments

Comments
 (0)