diff --git a/projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.spec.ts b/projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.spec.ts index a78def1ec2f..92cdaf4be87 100644 --- a/projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.spec.ts +++ b/projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.spec.ts @@ -255,6 +255,19 @@ describe('IgxForOf directive -', () => { } }); + it('should not throw error when itemSize is changed while data is null/undefined.', () => { + let errorMessage = ''; + fix.componentInstance.data = null; + fix.detectChanges(); + try { + fix.componentInstance.itemSize = '100px'; + fix.detectChanges(); + } catch (ex) { + errorMessage = ex.message; + } + expect(errorMessage).toBe(''); + }); + it('should allow initially undefined value for igxForOf and then detect changes correctly once the value is updated', async () => { fix = TestBed.createComponent(VerticalVirtualNoDataComponent); expect(() => { diff --git a/projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts b/projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts index 1971d1e72bb..8115f7a49a1 100644 --- a/projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts +++ b/projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts @@ -423,7 +423,8 @@ export class IgxForOfDirective implements OnInit, OnChanges, DoCheck, OnDestr } } const defaultItemSize = 'igxForItemSize'; - if (defaultItemSize in changes && !changes[defaultItemSize].firstChange && this.igxForScrollOrientation === 'vertical') { + if (defaultItemSize in changes && !changes[defaultItemSize].firstChange && + this.igxForScrollOrientation === 'vertical' && this.igxForOf) { // handle default item size changed. this.initSizesCache(this.igxForOf); this._applyChanges(); @@ -1325,7 +1326,8 @@ export class IgxGridForOfDirective extends IgxForOfDirective implements On } } const defaultItemSize = 'igxForItemSize'; - if (defaultItemSize in changes && !changes[defaultItemSize].firstChange && this.igxForScrollOrientation === 'vertical') { + if (defaultItemSize in changes && !changes[defaultItemSize].firstChange && + this.igxForScrollOrientation === 'vertical' && this.igxForOf) { // handle default item size changed. this.initSizesCache(this.igxForOf); } diff --git a/src/app/hierarchical-grid-remote/hierarchical-grid-remote.sample.html b/src/app/hierarchical-grid-remote/hierarchical-grid-remote.sample.html index 7882095dd70..1835cc644c7 100644 --- a/src/app/hierarchical-grid-remote/hierarchical-grid-remote.sample.html +++ b/src/app/hierarchical-grid-remote/hierarchical-grid-remote.sample.html @@ -1,6 +1,6 @@ - +