Skip to content

Commit ae77759

Browse files
authored
Merge pull request #11425 from IgniteUI/mdragnev/11364
fix(Pivot): Remove a check if scrollComponent is already in the dom
2 parents 5ff1ac1 + 1b01d3f commit ae77759

File tree

2 files changed

+45
-25
lines changed

2 files changed

+45
-25
lines changed

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

Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -288,29 +288,6 @@ describe('IgxForOf directive -', () => {
288288
expect(errorMessage).toBe('');
289289
});
290290

291-
it('should allow initially undefined value for igxForOf and then detect changes correctly once the value is updated', () => {
292-
fix = TestBed.createComponent(VerticalVirtualNoDataComponent);
293-
expect(() => {
294-
fix.detectChanges();
295-
}).not.toThrow();
296-
displayContainer = fix.nativeElement.querySelector(DISPLAY_CONTAINER);
297-
verticalScroller = fix.nativeElement.querySelector(VERTICAL_SCROLLER);
298-
expect(displayContainer).not.toBeNull();
299-
expect(verticalScroller).not.toBeNull();
300-
301-
fix.componentInstance.height = '400px';
302-
fix.detectChanges();
303-
fix.componentInstance.height = '500px';
304-
fix.detectChanges();
305-
306-
let rowsRendered = displayContainer.querySelectorAll('div');
307-
expect(rowsRendered.length).toBe(0);
308-
fix.componentInstance.data = dg.generateVerticalData(fix.componentInstance.cols);
309-
fix.detectChanges();
310-
rowsRendered = displayContainer.querySelectorAll('div');
311-
expect(rowsRendered.length).not.toBe(0);
312-
});
313-
314291
it('should always fill available space for last chunk size calculation - vertical virtualization', async () => {
315292
fix.componentInstance.height = '1900px';
316293
const virtualContainer = fix.componentInstance.parentVirtDir;
@@ -379,6 +356,49 @@ describe('IgxForOf directive -', () => {
379356
});
380357
});
381358

359+
describe('vertical virtual component no data', () => {
360+
let fix: ComponentFixture<VerticalVirtualComponent>;
361+
configureTestSuite();
362+
beforeAll(waitForAsync(() => {
363+
TestBed.configureTestingModule({
364+
declarations: [
365+
TestIgxForOfDirective,
366+
VerticalVirtualNoDataComponent,
367+
VerticalVirtualComponent
368+
],
369+
imports: [IgxForOfModule],
370+
providers: [{ provide: NgZone, useFactory: () => new TestNgZone() }]
371+
}).compileComponents();
372+
}));
373+
374+
beforeEach(() => {
375+
fix = TestBed.createComponent(VerticalVirtualNoDataComponent);
376+
});
377+
378+
it('should allow initially undefined value for igxForOf and then detect changes correctly once the value is updated', () => {
379+
expect(() => {
380+
fix.detectChanges();
381+
}).not.toThrow();
382+
displayContainer = fix.nativeElement.querySelector(DISPLAY_CONTAINER);
383+
verticalScroller = fix.nativeElement.querySelector(VERTICAL_SCROLLER);
384+
expect(displayContainer).not.toBeNull();
385+
expect(verticalScroller).not.toBeNull();
386+
387+
fix.componentInstance.height = '400px';
388+
fix.detectChanges();
389+
fix.componentInstance.height = '500px';
390+
fix.detectChanges();
391+
392+
let rowsRendered = displayContainer.querySelectorAll('div');
393+
expect(rowsRendered.length).toBe(0);
394+
fix.componentInstance.data = dg.generateVerticalData(fix.componentInstance.cols);
395+
fix.detectChanges();
396+
rowsRendered = displayContainer.querySelectorAll('div');
397+
expect(rowsRendered.length).not.toBe(0);
398+
});
399+
400+
});
401+
382402
describe('vertical and horizontal virtual component', () => {
383403
let fix: ComponentFixture<VirtualComponent>;
384404

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
423423
if (this.igxForScrollOrientation === 'vertical') {
424424
this.dc.instance._viewContainer.element.nativeElement.style.top = '0px';
425425
this.scrollComponent = this.syncScrollService.getScrollMaster(this.igxForScrollOrientation);
426-
if (!this.scrollComponent || !this.document.contains(this.scrollComponent.elementRef.nativeElement)) {
427-
this.scrollComponent = vc.createComponent(VirtualHelperComponent).instance
426+
if (!this.scrollComponent || this.scrollComponent.destroyed) {
427+
this.scrollComponent = vc.createComponent(VirtualHelperComponent).instance;
428428
}
429429
this._maxHeight = this._calcMaxBrowserHeight();
430430
this.scrollComponent.size = this.igxForOf ? this._calcHeight() : 0;

0 commit comments

Comments
 (0)