Skip to content

Commit 3f8d1c8

Browse files
Merge pull request #16520 from IgniteUI/bpachilova/ariaHidden-header-groups-fix-16517
fix(grid): address null TypeError on focusing a grid with no data and column headers - master
2 parents 3f5e5ef + 01e5139 commit 3f8d1c8

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class IgxGridHeaderGroupComponent implements DoCheck {
151151
* @hidden
152152
*/
153153
public get ariaHidden(): boolean {
154-
return this.grid.hasColumnGroups && (this.column.hidden || this.grid.navigation.activeNode.row !== -1);
154+
return this.grid.hasColumnGroups && (this.column.hidden || this.grid.navigation.activeNode?.row !== -1);
155155
}
156156

157157
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class IgxGridHeaderRowComponent implements DoCheck {
123123
* @internal
124124
*/
125125
public get isLeafHeaderAriaHidden(): boolean {
126-
return this.grid.navigation.activeNode.row === -1;
126+
return this.grid.navigation.activeNode?.row === -1;
127127
}
128128

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

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

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

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

0 commit comments

Comments
 (0)