@@ -8,6 +8,7 @@ import { IgxRowIslandComponent } from './row-island.component';
88import { wait } from '../../test-utils/ui-interactions.spec' ;
99import { FilteringExpressionsTree , FilteringLogic , IgxStringFilteringOperand } from 'igniteui-angular' ;
1010import { By } from '@angular/platform-browser' ;
11+ import { first , delay } from 'rxjs/operators' ;
1112
1213describe ( 'IgxHierarchicalGrid Virtualization' , ( ) => {
1314 configureTestSuite ( ) ;
@@ -339,6 +340,74 @@ describe('IgxHierarchicalGrid Virtualization', () => {
339340 expect ( childRowComponent . index ) . toBe ( 4 ) ;
340341 } ) ;
341342
343+ it ( 'should update scrollbar when expanding a row with data loaded after initial view initialization' , async ( done ) => {
344+ fixture . componentInstance . data = fixture . componentInstance . generateData ( 10 , 0 ) ;
345+ fixture . detectChanges ( ) ;
346+
347+ fixture . componentInstance . rowIsland . onGridCreated . pipe ( first ( ) , delay ( 200 ) ) . subscribe (
348+ async ( args ) => {
349+ args . grid . data = fixture . componentInstance . generateData ( 10 , 0 ) ;
350+ await wait ( 200 ) ;
351+ fixture . detectChanges ( ) ;
352+
353+ expect ( hierarchicalGrid . verticalScrollContainer . getVerticalScroll ( ) . children [ 0 ] . offsetHeight ) . toEqual ( 1184 ) ;
354+ done ( ) ;
355+ }
356+ ) ;
357+
358+
359+ expect ( hierarchicalGrid . verticalScrollContainer . getVerticalScroll ( ) . children [ 0 ] . offsetHeight ) . toEqual ( 500 ) ;
360+
361+ // expand 1st row
362+ const row = hierarchicalGrid . dataRowList . toArray ( ) [ 0 ] ;
363+ row . nativeElement . children [ 0 ] . click ( ) ;
364+ fixture . detectChanges ( ) ;
365+
366+ expect ( hierarchicalGrid . verticalScrollContainer . getVerticalScroll ( ) . children [ 0 ] . offsetHeight ) . toEqual ( 550 ) ;
367+ } ) ;
368+ } ) ;
369+
370+ describe ( 'IgxHierarchicalGrid Virtualization Custom Scenarios' , ( ) => {
371+ configureTestSuite ( ) ;
372+ beforeEach ( async ( ( ) => {
373+ TestBed . configureTestingModule ( {
374+ declarations : [
375+ IgxHierarchicalGridTestBaseComponent ,
376+ IgxHierarchicalGridNoScrollTestComponent
377+ ] ,
378+ imports : [
379+ NoopAnimationsModule , IgxHierarchicalGridModule ]
380+ } ) . compileComponents ( ) ;
381+ } ) ) ;
382+
383+ it ( 'should show scrollbar after expanding a row with data loaded after initial view initialization' , async ( done ) => {
384+ const fixture = TestBed . createComponent ( IgxHierarchicalGridNoScrollTestComponent ) ;
385+ fixture . detectChanges ( ) ;
386+
387+ const hierarchicalGrid = fixture . componentInstance . hgrid ;
388+ fixture . componentInstance . rowIsland . onGridCreated . pipe ( first ( ) , delay ( 200 ) ) . subscribe (
389+ async ( args ) => {
390+ args . grid . data = fixture . componentInstance . generateData ( 10 , 0 ) ;
391+ await wait ( 200 ) ;
392+ fixture . detectChanges ( ) ;
393+
394+ expect ( hierarchicalGrid . verticalScrollContainer . getVerticalScroll ( ) . parentElement . hidden ) . toBeFalsy ( ) ;
395+ expect ( hierarchicalGrid . tbody . nativeElement . offsetWidth ) . toBeLessThan ( initialBodyWidth ) ;
396+ done ( ) ;
397+ }
398+ ) ;
399+
400+ const initialBodyWidth = hierarchicalGrid . tbody . nativeElement . offsetWidth ;
401+ expect ( hierarchicalGrid . verticalScrollContainer . getVerticalScroll ( ) . parentElement . hidden ) . toBeTruthy ( ) ;
402+
403+ // expand 1st row
404+ const row = hierarchicalGrid . dataRowList . toArray ( ) [ 0 ] ;
405+ row . nativeElement . children [ 0 ] . click ( ) ;
406+ fixture . detectChanges ( ) ;
407+
408+ expect ( hierarchicalGrid . verticalScrollContainer . getVerticalScroll ( ) . parentElement . hidden ) . toBeTruthy ( ) ;
409+ expect ( hierarchicalGrid . tbody . nativeElement . offsetWidth ) . toEqual ( initialBodyWidth ) ;
410+ } ) ;
342411} ) ;
343412
344413@Component ( {
@@ -377,3 +446,20 @@ export class IgxHierarchicalGridTestBaseComponent {
377446 return prods ;
378447 }
379448}
449+
450+ @Component ( {
451+ template : `
452+ <igx-hierarchical-grid #grid1 [data]="data" [allowFiltering]="true"
453+ [autoGenerate]="true" [height]="'400px'" [width]="'500px'" #hierarchicalGrid primaryKey="ID">
454+ <igx-row-island [key]="'childData'" [autoGenerate]="true" [allowFiltering]="true" #rowIsland>
455+ <igx-row-island [key]="'childData'" [autoGenerate]="true" #rowIsland2 >
456+ </igx-row-island>
457+ </igx-row-island>
458+ </igx-hierarchical-grid>`
459+ } )
460+ export class IgxHierarchicalGridNoScrollTestComponent extends IgxHierarchicalGridTestBaseComponent {
461+ constructor ( ) {
462+ super ( ) ;
463+ this . data = this . generateData ( 3 , 0 ) ;
464+ }
465+ }
0 commit comments