diff --git a/projects/igniteui-angular/src/lib/grids/grid/column-group.spec.ts b/projects/igniteui-angular/src/lib/grids/grid/column-group.spec.ts index 01f954a99e0..4cd61fbe4af 100644 --- a/projects/igniteui-angular/src/lib/grids/grid/column-group.spec.ts +++ b/projects/igniteui-angular/src/lib/grids/grid/column-group.spec.ts @@ -204,6 +204,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; diff --git a/projects/igniteui-angular/src/lib/grids/headers/grid-header-group.component.ts b/projects/igniteui-angular/src/lib/grids/headers/grid-header-group.component.ts index fd1ec6cc014..2fd89ec6114 100644 --- a/projects/igniteui-angular/src/lib/grids/headers/grid-header-group.component.ts +++ b/projects/igniteui-angular/src/lib/grids/headers/grid-header-group.component.ts @@ -161,7 +161,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/src/lib/grids/headers/grid-header-row.component.ts b/projects/igniteui-angular/src/lib/grids/headers/grid-header-row.component.ts index 756c61d0afa..d6ffc9e25b8 100644 --- a/projects/igniteui-angular/src/lib/grids/headers/grid-header-row.component.ts +++ b/projects/igniteui-angular/src/lib/grids/headers/grid-header-row.component.ts @@ -118,7 +118,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. */