Skip to content

Commit 22e4fbe

Browse files
committed
refactor(grid-base): aria-rowcount calculation
1 parent 7e58f07 commit 22e4fbe

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,15 @@ export abstract class IgxGridBaseDirective implements GridType,
18391839
@HostBinding('class.igx-grid')
18401840
protected baseClass = 'igx-grid';
18411841

1842+
@HostBinding('attr.aria-colcount')
1843+
protected get ariaColCount(): number {
1844+
return this.visibleColumns.length;
1845+
}
1846+
1847+
@HostBinding('attr.aria-rowcount')
1848+
protected get ariaRowCount(): number {
1849+
return this._rendered ? this._rowCount : null;
1850+
}
18421851

18431852
/**
18441853
* Gets/Sets the resource strings.
@@ -3299,6 +3308,7 @@ export abstract class IgxGridBaseDirective implements GridType,
32993308
private _sortDescendingHeaderIconTemplate: TemplateRef<IgxGridHeaderTemplateContext> = null;
33003309
private _gridSize: Size = Size.Large;
33013310
private _defaultRowHeight = 50;
3311+
private _rowCount: number;
33023312

33033313
/**
33043314
* @hidden @internal
@@ -4120,6 +4130,7 @@ export abstract class IgxGridBaseDirective implements GridType,
41204130
if (this.hasColumnsToAutosize) {
41214131
this.autoSizeColumnsInView();
41224132
}
4133+
this._calculateRowCount();
41234134
this._rendered = true;
41244135
});
41254136
Promise.resolve().then(() => this.rendered.next(true));
@@ -6762,6 +6773,7 @@ export abstract class IgxGridBaseDirective implements GridType,
67626773

67636774
this.initColumns(this._columns, (col: IgxColumnComponent) => this.columnInit.emit(col));
67646775
this.columnListDiffer.diff(this.columnList);
6776+
this._calculateRowCount();
67656777

67666778
this.columnList.changes
67676779
.pipe(takeUntil(this.destroy$))
@@ -7985,4 +7997,15 @@ export abstract class IgxGridBaseDirective implements GridType,
79857997
return recreateTreeFromFields(value, this._columns) as IFilteringExpressionsTree;
79867998
}
79877999
}
8000+
8001+
private _calculateRowCount(): void {
8002+
if (this.verticalScrollContainer?.isRemote) {
8003+
this._rowCount = this.verticalScrollContainer.totalItemCount ?? 0;
8004+
} else if (this.paginator) {
8005+
this._rowCount = this.totalRecords ?? 0;
8006+
} else {
8007+
this._rowCount = this.verticalScrollContainer?.igxForOf?.length ?? 0;
8008+
}
8009+
this._rowCount += 1; // include header row
8010+
}
79888011
}

0 commit comments

Comments
 (0)