Skip to content

Commit 52aa232

Browse files
authored
Merge pull request #5832 from IgniteUI/mkirova/fix-5683
fix(igxHierarchicalGrid): Error is thrown on child grid initializatio…
2 parents a2d05b9 + c767ff8 commit 52aa232

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,19 @@ describe('IgxForOf directive -', () => {
256256
}
257257
});
258258

259+
it('should not throw error when itemSize is changed while data is null/undefined.', () => {
260+
let errorMessage = '';
261+
fix.componentInstance.data = null;
262+
fix.detectChanges();
263+
try {
264+
fix.componentInstance.itemSize = '100px';
265+
fix.detectChanges();
266+
} catch (ex) {
267+
errorMessage = ex.message;
268+
}
269+
expect(errorMessage).toBe('');
270+
});
271+
259272
it('should allow initially undefined value for igxForOf and then detect changes correctly once the value is updated', async () => {
260273
fix = TestBed.createComponent(VerticalVirtualNoDataComponent);
261274
expect(() => {

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
391391
}
392392
}
393393
const defaultItemSize = 'igxForItemSize';
394-
if (defaultItemSize in changes && !changes[defaultItemSize].firstChange && this.igxForScrollOrientation === 'vertical') {
394+
if (defaultItemSize in changes && !changes[defaultItemSize].firstChange &&
395+
this.igxForScrollOrientation === 'vertical' && this.igxForOf) {
395396
// handle default item size changed.
396397
this.initSizesCache(this.igxForOf);
397398
this._applyChanges();
@@ -1290,7 +1291,8 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
12901291
}
12911292
}
12921293
const defaultItemSize = 'igxForItemSize';
1293-
if (defaultItemSize in changes && !changes[defaultItemSize].firstChange && this.igxForScrollOrientation === 'vertical') {
1294+
if (defaultItemSize in changes && !changes[defaultItemSize].firstChange &&
1295+
this.igxForScrollOrientation === 'vertical' && this.igxForOf) {
12941296
// handle default item size changed.
12951297
this.initSizesCache(this.igxForOf);
12961298
}

src/app/hierarchical-grid-remote/hierarchical-grid-remote.sample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<button (click)='setterBindingChange()'>Set rowSelectable via binding</button>
22
<button (click)='setterChange()'>Set rowSelectable via setter on 1st row island</button>
3-
<igx-hierarchical-grid #grid1 [data]="remoteData" [primaryKey]="'CustomerID'" [autoGenerate]="false" [height]="'800px'" [width]="'100%'" #hGrid [emptyGridMessage]="''">
3+
<igx-hierarchical-grid #grid1 displayDensity="cosy" [data]="remoteData" [primaryKey]="'CustomerID'" [autoGenerate]="false" [height]="'800px'" [width]="'100%'" #hGrid [emptyGridMessage]="''">
44
<igx-column field="CustomerID"></igx-column>
55
<igx-column field="CompanyName"></igx-column>
66
<igx-column field="ContactName"></igx-column>

0 commit comments

Comments
 (0)