Skip to content

Commit 79b2df1

Browse files
committed
fix(cell): add row and col index aria attrs
1 parent 301cda0 commit 79b2df1

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

projects/igniteui-angular/src/lib/grids/cell.component.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,16 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy, CellT
703703
}
704704
}
705705

706+
@HostBinding('attr.aria-rowindex')
707+
protected get ariaRowIndex(): number {
708+
return this.rowIndex + 1;
709+
}
710+
711+
@HostBinding('attr.aria-colindex')
712+
protected get ariaColIndex(): number {
713+
return this.visibleColumnIndex + 1;
714+
}
715+
706716
@ViewChild('defaultCell', { read: TemplateRef, static: true })
707717
protected defaultCellTemplate: TemplateRef<any>;
708718

projects/igniteui-angular/src/lib/grids/grid/grid.component.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,28 @@ describe('IgxGrid Component Tests #grid', () => {
20042004
expect(grid.columns[1].field).toBe('firstName');
20052005
expect(grid.columns[2].field).toBe('lastName');
20062006
}));
2007+
2008+
it('should specify the correct aria-rowindex and aria-colindex attributes for cells', async () => {
2009+
const fix = TestBed.createComponent(IgxGridDefaultRenderingComponent);
2010+
fix.componentInstance.initColumnsRows(80, 20);
2011+
fix.detectChanges();
2012+
fix.detectChanges();
2013+
2014+
const grid = fix.componentInstance.grid;
2015+
2016+
grid.navigateTo(50, 16);
2017+
fix.detectChanges();
2018+
await wait();
2019+
fix.detectChanges();
2020+
2021+
const cell = grid.gridAPI.get_cell_by_index(50, 'col16');
2022+
// The following attributes indicate to assistive technologies which portions
2023+
// of the content are displayed in case not all are rendered,
2024+
// such as with the built-in virtualization of the grid. 1-based index.
2025+
expect(cell.nativeElement.getAttribute('aria-rowindex')).toBe('51');
2026+
expect(cell.nativeElement.getAttribute('aria-colindex')).toBe('17');
2027+
2028+
});
20072029
});
20082030

20092031
describe('IgxGrid - min/max width constraints rules', () => {

0 commit comments

Comments
 (0)