Skip to content

Commit 441b8f8

Browse files
authored
fix(grid): fix out of bounds row index when navigating down from last layout row - master (#16755)
1 parent 03e0265 commit 441b8f8

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,8 @@ export class IgxGridMRLNavigationService extends IgxGridNavigationService {
354354

355355
private hasNextVerticalPosition(prev = false) {
356356
if ((prev && this.activeNode.row === 0 && (!this.isDataRow(this.activeNode.row) || this.activeNode.layout.rowStart === 1)) ||
357-
(!prev && this.activeNode.row >= this.grid.dataView.length - 1 && this.activeNode.column === this.lastColIndexPerMRLBlock())) {
357+
(!prev && this.activeNode.row >= this.grid.dataView.length - 1 &&
358+
this.activeNode.layout.rowStart === this.lastRowStartPerBlock())) {
358359
return false;
359360
}
360361
return true;

projects/igniteui-angular/grids/grid/src/grid-mrl-keyboard-nav.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,40 @@ describe('IgxGrid Multi Row Layout - Keyboard navigation #grid', () => {
301301
GridFunctions.verifyGridContentActiveDescendant(GridFunctions.getGridContent(fix), cell.nativeElement.id);
302302
});
303303

304+
it('should not return an out of bounds row index when navigating down from the last layout row', () => {
305+
fix.componentInstance.data = SampleTestData.contactInfoDataFull().slice(0, 10);
306+
fix.componentInstance.colGroups = [{
307+
group: 'group1',
308+
columns: [
309+
{ field: 'ID', rowStart: 1, colStart: 1 },
310+
{ field: 'CompanyName', rowStart: 1, colStart: 2 },
311+
{ field: 'ContactName', rowStart: 1, colStart: 3 },
312+
{ field: 'ContactTitle', rowStart: 1, colStart: 4 },
313+
{ field: 'Address', rowStart: 1, colStart: 5 },
314+
{ field: 'City', rowStart: 2, colStart: 1 },
315+
{ field: 'Region', rowStart: 2, colStart: 2 },
316+
{ field: 'PostalCode', rowStart: 2, colStart: 3 },
317+
{ field: 'Phone', rowStart: 2, colStart: 4 },
318+
{ field: 'Fax', rowStart: 2, colStart: 5 }
319+
]
320+
}];
321+
fix.detectChanges();
322+
323+
const grid = fix.componentInstance.grid;
324+
const lastRowIndex = grid.dataView.length - 1;
325+
const navService = grid.navigation as IgxGridMRLNavigationService;
326+
const col = grid.getColumnByName('City');
327+
navService.setActiveNode({
328+
row: lastRowIndex,
329+
column: col.visibleIndex,
330+
layout: navService.layout(col.visibleIndex)
331+
});
332+
333+
const nextPos = navService.getNextVerticalPosition();
334+
expect(nextPos.row).toBe(lastRowIndex);
335+
expect(nextPos.column).toBe(navService.activeNode.column);
336+
});
337+
304338
it('should navigate up correctly', () => {
305339
fix.componentInstance.colGroups = [{
306340
group: 'group1',

0 commit comments

Comments
 (0)