Skip to content

Address grids column headers accessibility issues - active descendant, what is announced by SRs - 20.0.x #15982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
43db615
test(grids): check active descendant for focused/selected cells
ddaribo Jun 24, 2025
feefc10
fix(grids): active descendant points to the active column header
ddaribo Jun 24, 2025
2a350c4
Merge branch '20.0.x' into bpachilova/column-headers-a11y-15962
ddaribo Jun 25, 2025
e7c5d8f
fix(pivot): headers activedescendants & clean up redundant row/rowgro…
ddaribo Jun 26, 2025
f9c683d
test(pivot): column & row headers activedescendant
ddaribo Jun 26, 2025
aae6481
Merge branch '20.0.x' into bpachilova/column-headers-a11y-15962
ddaribo Jun 26, 2025
8d68f82
fix(pivot): correct header ID binding logic in template
ddaribo Jun 26, 2025
c3e6824
fix(cell): point describedby to correct ID and fix tests
ddaribo Jun 27, 2025
d7fd748
feat(grids): add aria-sort attribute to column headers + test checks
ddaribo Jun 27, 2025
a5c8d73
Merge branch '20.0.x' into bpachilova/column-headers-a11y-15962
ddaribo Jun 27, 2025
64f9aeb
fix(cell): add row and col index aria attrs
ddaribo Jun 30, 2025
2c9a5b3
feat(grid): correct aria attributes related to total rows/cols count …
ddaribo Jun 30, 2025
693a735
Merge branch '20.0.x' into bpachilova/column-headers-a11y-15962
ddaribo Jul 2, 2025
05faaa2
refactor(cell, header): use headerCell.id for aria-describedby
ddaribo Jul 21, 2025
5eccd74
refactor(grid-base): aria-rowcount calculation
ddaribo Jul 21, 2025
45bd8e3
Merge branch '20.0.x' into bpachilova/column-headers-a11y-15962
ddaribo Aug 7, 2025
293b082
Merge branch '20.0.x' into bpachilova/column-headers-a11y-15962
kacheshmarova Aug 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions projects/igniteui-angular/src/lib/grids/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,17 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy, CellT
}
}

@HostBinding('attr.aria-rowindex')
protected get ariaRowIndex(): number {
// +2 because aria-rowindex is 1-based and the first row is the header
return this.rowIndex + 2;
}

@HostBinding('attr.aria-colindex')
protected get ariaColIndex(): number {
return this.column.index + 1;
}

@ViewChild('defaultCell', { read: TemplateRef, static: true })
protected defaultCellTemplate: TemplateRef<any>;

Expand Down
32 changes: 26 additions & 6 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,15 @@ export abstract class IgxGridBaseDirective implements GridType,
@HostBinding('class.igx-grid')
protected baseClass = 'igx-grid';

@HostBinding('attr.aria-colcount')
protected get ariaColCount(): number {
return this.visibleColumns.length;
}

@HostBinding('attr.aria-rowcount')
protected get ariaRowCount(): number {
return this._rendered ? this._rowCount : null;
}

/**
* Gets/Sets the resource strings.
Expand Down Expand Up @@ -2765,13 +2774,10 @@ export abstract class IgxGridBaseDirective implements GridType,
public get activeDescendant() {
const activeElem = this.navigation.activeNode;

if (!activeElem || !Object.keys(activeElem).length) {
return this.id;
if (!activeElem || !Object.keys(activeElem).length || activeElem.row < 0) {
return null;
}

return activeElem.row < 0 ?
`${this.id}_${activeElem.row}_${activeElem.mchCache.level}_${activeElem.column}` :
`${this.id}_${activeElem.row}_${activeElem.column}`;
return `${this.id}_${activeElem.row}_${activeElem.column}`;
}

/** @hidden @internal */
Expand Down Expand Up @@ -3302,6 +3308,7 @@ export abstract class IgxGridBaseDirective implements GridType,
private _sortDescendingHeaderIconTemplate: TemplateRef<IgxGridHeaderTemplateContext> = null;
private _gridSize: Size = Size.Large;
private _defaultRowHeight = 50;
private _rowCount: number;

/**
* @hidden @internal
Expand Down Expand Up @@ -4123,6 +4130,7 @@ export abstract class IgxGridBaseDirective implements GridType,
if (this.hasColumnsToAutosize) {
this.autoSizeColumnsInView();
}
this._calculateRowCount();
this._rendered = true;
});
Promise.resolve().then(() => this.rendered.next(true));
Expand Down Expand Up @@ -6765,6 +6773,7 @@ export abstract class IgxGridBaseDirective implements GridType,

this.initColumns(this._columns, (col: IgxColumnComponent) => this.columnInit.emit(col));
this.columnListDiffer.diff(this.columnList);
this._calculateRowCount();

this.columnList.changes
.pipe(takeUntil(this.destroy$))
Expand Down Expand Up @@ -7988,4 +7997,15 @@ export abstract class IgxGridBaseDirective implements GridType,
return recreateTreeFromFields(value, this._columns) as IFilteringExpressionsTree;
}
}

private _calculateRowCount(): void {
if (this.verticalScrollContainer?.isRemote) {
this._rowCount = this.verticalScrollContainer.totalItemCount ?? 0;
} else if (this.paginator) {
this._rowCount = this.totalRecords ?? 0;
} else {
this._rowCount = this.verticalScrollContainer?.igxForOf?.length ?? 0;
}
this._rowCount += 1; // include header row
}
}
Loading
Loading