@@ -783,6 +783,73 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
783783 expect ( childGrids [ 1 ] . height ) . toBe ( '200px' ) ;
784784 } ) ;
785785
786+ it ( 'should hide child row editing overlay when parent scroll moves child row out of view' , ( ) => {
787+ hierarchicalGrid . getRowByIndex ( 0 ) . expanded = true ;
788+ fixture . detectChanges ( ) ;
789+
790+ const childGrid = hierarchicalGrid . gridAPI . getChildGrids ( ) [ 0 ] as IgxHierarchicalGridComponent ;
791+ childGrid . primaryKey = 'ID' ;
792+ childGrid . rowEditable = true ;
793+ fixture . detectChanges ( ) ;
794+
795+ const row = childGrid . gridAPI . get_row_by_index ( 0 ) ;
796+ spyOnProperty ( childGrid . crudService , 'rowInEditMode' , 'get' ) . and . returnValue ( row ) ;
797+ spyOnProperty ( childGrid . rowEditingOverlay , 'collapsed' , 'get' ) . and . returnValue ( false ) ;
798+ childGrid . rowEditingOverlay . element . style . display = 'block' ;
799+
800+ spyOn ( ( hierarchicalGrid as any ) . tbodyContainer . nativeElement , 'getBoundingClientRect' ) . and . returnValue ( {
801+ top : 0 ,
802+ bottom : 200
803+ } as DOMRect ) ;
804+ let childRowRect = {
805+ top : 40 ,
806+ bottom : 80
807+ } as DOMRect ;
808+ spyOn ( row . nativeElement , 'getBoundingClientRect' ) . and . callFake ( ( ) => childRowRect ) ;
809+ const repositionOverlaySpy = spyOn ( childGrid , 'repositionRowEditingOverlay' ) ;
810+ const toggleOverlaySpy = spyOn ( childGrid , 'toggleRowEditingOverlay' ) . and . callThrough ( ) ;
811+
812+ const scroll = hierarchicalGrid . verticalScrollContainer . getScroll ( ) ;
813+ scroll . scrollTop = 10 ;
814+ ( hierarchicalGrid as any ) . verticalScrollHandler ( { target : scroll } ) ;
815+ ( hierarchicalGrid as any ) . zone . onStable . emit ( null ) ;
816+ fixture . detectChanges ( ) ;
817+
818+ expect ( repositionOverlaySpy ) . toHaveBeenCalledWith ( row ) ;
819+ expect ( toggleOverlaySpy ) . not . toHaveBeenCalledWith ( false ) ;
820+ expect ( childGrid . rowEditingOverlay . element . style . display ) . not . toBe ( 'none' ) ;
821+
822+ repositionOverlaySpy . calls . reset ( ) ;
823+ toggleOverlaySpy . calls . reset ( ) ;
824+ childRowRect = {
825+ top : - 80 ,
826+ bottom : - 40
827+ } as DOMRect ;
828+ scroll . scrollTop = 1000 ;
829+ ( hierarchicalGrid as any ) . verticalScrollHandler ( { target : scroll } ) ;
830+ ( hierarchicalGrid as any ) . zone . onStable . emit ( null ) ;
831+ fixture . detectChanges ( ) ;
832+
833+ expect ( repositionOverlaySpy ) . not . toHaveBeenCalled ( ) ;
834+ expect ( toggleOverlaySpy ) . toHaveBeenCalledWith ( false ) ;
835+ expect ( childGrid . rowEditingOverlay . element . style . display ) . toBe ( 'none' ) ;
836+
837+ repositionOverlaySpy . calls . reset ( ) ;
838+ toggleOverlaySpy . calls . reset ( ) ;
839+ childRowRect = {
840+ top : 40 ,
841+ bottom : 80
842+ } as DOMRect ;
843+ scroll . scrollTop = 10 ;
844+ ( hierarchicalGrid as any ) . verticalScrollHandler ( { target : scroll } ) ;
845+ ( hierarchicalGrid as any ) . zone . onStable . emit ( null ) ;
846+ fixture . detectChanges ( ) ;
847+
848+ expect ( toggleOverlaySpy ) . toHaveBeenCalledWith ( true ) ;
849+ expect ( repositionOverlaySpy ) . toHaveBeenCalledWith ( row ) ;
850+ expect ( childGrid . rowEditingOverlay . element . style . display ) . not . toBe ( 'none' ) ;
851+ } ) ;
852+
786853 it ( 'Should apply runtime option changes to all related child grids (both existing and not yet initialized).' , ( ) => {
787854 const row = hierarchicalGrid . gridAPI . get_row_by_index ( 0 ) as IgxHierarchicalRowComponent ;
788855 UIInteractions . simulateClickAndSelectEvent ( row . expander ) ;
0 commit comments