Skip to content

Commit 4f2d285

Browse files
committed
refactor(grid-base): aria-rowcount calculation
1 parent 05faaa2 commit 4f2d285

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,8 +1846,7 @@ export abstract class IgxGridBaseDirective implements GridType,
18461846

18471847
@HostBinding('attr.aria-rowcount')
18481848
protected get ariaRowCount(): number {
1849-
const totalRows = (this as any).totalItemCount ?? this.data?.length ?? 0;
1850-
return (this.paginator ? this._totalRecords : totalRows) + 1;
1849+
return this._rendered ? this._rowCount : null;
18511850
}
18521851

18531852
/**
@@ -3309,6 +3308,7 @@ export abstract class IgxGridBaseDirective implements GridType,
33093308
private _sortDescendingHeaderIconTemplate: TemplateRef<IgxGridHeaderTemplateContext> = null;
33103309
private _gridSize: Size = Size.Large;
33113310
private _defaultRowHeight = 50;
3311+
private _rowCount: number;
33123312

33133313
/**
33143314
* @hidden @internal
@@ -3977,6 +3977,7 @@ export abstract class IgxGridBaseDirective implements GridType,
39773977
this._shouldRecalcRowHeight = false;
39783978
this.updateDefaultRowHeight();
39793979
}
3980+
this._calculateRowCount();
39803981
this.dataChanged.emit(event);
39813982
}
39823983

@@ -4130,6 +4131,7 @@ export abstract class IgxGridBaseDirective implements GridType,
41304131
if (this.hasColumnsToAutosize) {
41314132
this.autoSizeColumnsInView();
41324133
}
4134+
this._calculateRowCount();
41334135
this._rendered = true;
41344136
});
41354137
Promise.resolve().then(() => this.rendered.next(true));
@@ -7995,4 +7997,15 @@ export abstract class IgxGridBaseDirective implements GridType,
79957997
return recreateTreeFromFields(value, this._columns) as IFilteringExpressionsTree;
79967998
}
79977999
}
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+
}
79988011
}

0 commit comments

Comments
 (0)