diff --git a/projects/igniteui-angular/grids/core/src/headers/grid-header-group.component.ts b/projects/igniteui-angular/grids/core/src/headers/grid-header-group.component.ts index 07595de14aa..9a5de67f9be 100644 --- a/projects/igniteui-angular/grids/core/src/headers/grid-header-group.component.ts +++ b/projects/igniteui-angular/grids/core/src/headers/grid-header-group.component.ts @@ -151,7 +151,7 @@ export class IgxGridHeaderGroupComponent implements DoCheck { * @hidden */ public get ariaHidden(): boolean { - return this.grid.hasColumnGroups && (this.column.hidden || this.grid.navigation.activeNode.row !== -1); + return this.grid.hasColumnGroups && (this.column.hidden || this.grid.navigation.activeNode?.row !== -1); } /** diff --git a/projects/igniteui-angular/grids/core/src/headers/grid-header-row.component.ts b/projects/igniteui-angular/grids/core/src/headers/grid-header-row.component.ts index 93ab924c2fd..6646a57fb4f 100644 --- a/projects/igniteui-angular/grids/core/src/headers/grid-header-row.component.ts +++ b/projects/igniteui-angular/grids/core/src/headers/grid-header-row.component.ts @@ -123,7 +123,7 @@ export class IgxGridHeaderRowComponent implements DoCheck { * @internal */ public get isLeafHeaderAriaHidden(): boolean { - return this.grid.navigation.activeNode.row === -1; + return this.grid.navigation.activeNode?.row === -1; } /** The virtualized part of the header row containing the unpinned header groups. */ diff --git a/projects/igniteui-angular/grids/grid/src/column-group.spec.ts b/projects/igniteui-angular/grids/grid/src/column-group.spec.ts index dfbbbaaaac2..232dc7f0d15 100644 --- a/projects/igniteui-angular/grids/grid/src/column-group.spec.ts +++ b/projects/igniteui-angular/grids/grid/src/column-group.spec.ts @@ -203,6 +203,27 @@ describe('IgxGrid - multi-column headers #grid', () => { } })); + it('The ariaHidden getter should not throw when the grid has no active node (#16517)', fakeAsync(() => { + fixture = TestBed.createComponent(BlueWhaleGridComponent) as ComponentFixture; + tick(); + fixture.detectChanges(); + + // The grid active node will be null if there is no data and the body is focused + grid = fixture.componentInstance.grid; + grid.data = []; + + tick(); + fixture.detectChanges(); + + const gridContent = GridFunctions.getGridContent(fixture); + + expect(() => { + gridContent.triggerEventHandler('focus', null); + tick(400); + fixture.detectChanges(); + }).not.toThrow(); + })); + it('Should render dynamic column group header correctly (#12165).', () => { fixture = TestBed.createComponent(BlueWhaleGridComponent) as ComponentFixture; (fixture as ComponentFixture).componentInstance.firstGroupRepeats = 1;