Skip to content

Commit d04160e

Browse files
committed
refactor(grid-base): aria-rowcount calculation
1 parent 52655c3 commit d04160e

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
@@ -1808,6 +1808,15 @@ export abstract class IgxGridBaseDirective implements GridType,
18081808
@HostBinding('class.igx-grid')
18091809
protected baseClass = 'igx-grid';
18101810

1811+
@HostBinding('attr.aria-colcount')
1812+
protected get ariaColCount(): number {
1813+
return this.visibleColumns.length;
1814+
}
1815+
1816+
@HostBinding('attr.aria-rowcount')
1817+
protected get ariaRowCount(): number {
1818+
return this._rendered ? this._rowCount : null;
1819+
}
18111820

18121821
/**
18131822
* Gets/Sets the resource strings.
@@ -3266,6 +3275,7 @@ export abstract class IgxGridBaseDirective implements GridType,
32663275
private _sortDescendingHeaderIconTemplate: TemplateRef<IgxGridHeaderTemplateContext> = null;
32673276
private _gridSize: Size = Size.Large;
32683277
private _defaultRowHeight = 50;
3278+
private _rowCount: number;
32693279

32703280
/**
32713281
* @hidden @internal
@@ -4087,6 +4097,7 @@ export abstract class IgxGridBaseDirective implements GridType,
40874097
if (this.hasColumnsToAutosize) {
40884098
this.autoSizeColumnsInView();
40894099
}
4100+
this._calculateRowCount();
40904101
this._rendered = true;
40914102
});
40924103
Promise.resolve().then(() => this.rendered.next(true));
@@ -6729,6 +6740,7 @@ export abstract class IgxGridBaseDirective implements GridType,
67296740

67306741
this.initColumns(this._columns, (col: IgxColumnComponent) => this.columnInit.emit(col));
67316742
this.columnListDiffer.diff(this.columnList);
6743+
this._calculateRowCount();
67326744

67336745
this.columnList.changes
67346746
.pipe(takeUntil(this.destroy$))
@@ -7952,4 +7964,15 @@ export abstract class IgxGridBaseDirective implements GridType,
79527964
return recreateTreeFromFields(value, this._columns) as IFilteringExpressionsTree;
79537965
}
79547966
}
7967+
7968+
private _calculateRowCount(): void {
7969+
if (this.verticalScrollContainer?.isRemote) {
7970+
this._rowCount = this.verticalScrollContainer.totalItemCount ?? 0;
7971+
} else if (this.paginator) {
7972+
this._rowCount = this.totalRecords ?? 0;
7973+
} else {
7974+
this._rowCount = this.verticalScrollContainer?.igxForOf?.length ?? 0;
7975+
}
7976+
this._rowCount += 1; // include header row
7977+
}
79557978
}

0 commit comments

Comments
 (0)