Skip to content

Commit 64ad089

Browse files
authored
Merge pull request #7657 from IgniteUI/ddincheva/headerFocus
Should be able to focus header when grid has no data - master
2 parents def5e72 + cb13c31 commit 64ad089

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

projects/igniteui-angular/src/lib/grids/grid-navigation.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export class IgxGridNavigationService {
172172

173173
focusTbody(event) {
174174
const gridRows = this.grid.verticalScrollContainer.totalItemCount ?? this.grid.dataView.length;
175+
if (gridRows < 1) { this.activeNode = null; return; }
175176
if (!this.activeNode || this.activeNode.row < 0 || this.activeNode.row > gridRows - 1) {
176177
this.activeNode = { row: 0, column: 0 };
177178
this.grid.navigateTo(0, 0, (obj) => {
@@ -182,7 +183,8 @@ export class IgxGridNavigationService {
182183
}
183184

184185
focusFirstCell(header = true) {
185-
if (this.activeNode && (this.activeNode.row === -1 || this.activeNode.row === this.grid.dataView.length)) { return; }
186+
if (this.grid.dataView.length && this.activeNode &&
187+
(this.activeNode.row === -1 || this.activeNode.row === this.grid.dataView.length)) { return; }
186188
this.activeNode = { row: header ? -1 : this.grid.dataView.length, column: 0,
187189
level: this.grid.hasColumnLayouts ? 1 : 0, mchCache: { level: 0, visibleIndex: 0} };
188190
this.performHorizontalScrollToCell(0);

0 commit comments

Comments
 (0)