Skip to content

Commit 0c42d9b

Browse files
Merge pull request #16522 from IgniteUI/bpachilova/ariaHidden-header-groups-fix-16517-19.2.x
fix(grid): address null TypeError on focusing a grid with no data and column headers - 19.2.x
2 parents 6b166ea + cfa3fb0 commit 0c42d9b

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

projects/igniteui-angular/src/lib/grids/grid/column-group.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,27 @@ describe('IgxGrid - multi-column headers #grid', () => {
204204
}
205205
}));
206206

207+
it('The ariaHidden getter should not throw when the grid has no active node (#16517)', fakeAsync(() => {
208+
fixture = TestBed.createComponent(BlueWhaleGridComponent) as ComponentFixture<BlueWhaleGridComponent>;
209+
tick();
210+
fixture.detectChanges();
211+
212+
// The grid active node will be null if there is no data and the body is focused
213+
grid = fixture.componentInstance.grid;
214+
grid.data = [];
215+
216+
tick();
217+
fixture.detectChanges();
218+
219+
const gridContent = GridFunctions.getGridContent(fixture);
220+
221+
expect(() => {
222+
gridContent.triggerEventHandler('focus', null);
223+
tick(400);
224+
fixture.detectChanges();
225+
}).not.toThrow();
226+
}));
227+
207228
it('Should render dynamic column group header correctly (#12165).', () => {
208229
fixture = TestBed.createComponent(BlueWhaleGridComponent) as ComponentFixture<BlueWhaleGridComponent>;
209230
(fixture as ComponentFixture<BlueWhaleGridComponent>).componentInstance.firstGroupRepeats = 1;

projects/igniteui-angular/src/lib/grids/headers/grid-header-group.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export class IgxGridHeaderGroupComponent implements DoCheck {
161161
* @hidden
162162
*/
163163
public get ariaHidden(): boolean {
164-
return this.grid.hasColumnGroups && (this.column.hidden || this.grid.navigation.activeNode.row !== -1);
164+
return this.grid.hasColumnGroups && (this.column.hidden || this.grid.navigation.activeNode?.row !== -1);
165165
}
166166

167167
/**

projects/igniteui-angular/src/lib/grids/headers/grid-header-row.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class IgxGridHeaderRowComponent implements DoCheck {
118118
* @internal
119119
*/
120120
public get isLeafHeaderAriaHidden(): boolean {
121-
return this.grid.navigation.activeNode.row === -1;
121+
return this.grid.navigation.activeNode?.row === -1;
122122
}
123123

124124
/** The virtualized part of the header row containing the unpinned header groups. */

0 commit comments

Comments
 (0)