@@ -292,35 +292,41 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
292292 } else {
293293 this . focusNextChildDOMElem ( currentRowEl , this . grid ) ;
294294 }
295+ } else if ( this . grid . parent && this . grid . parent . summariesRowList . length > 0 ) {
296+ this . _navigateToNextParentRow ( currentRowEl ) ;
295297 } else {
296298 this . navigateDown ( currentRowEl , { row : rowIndex , column : 0 } ) ;
297299 }
298300 } else if ( isLastSummaryRow && isLastColumn && this . grid . parent ) {
299- // navigating in child summary, next is parent summary or next parent row
300- const parent = this . grid . parent ;
301- const parentHasSummary = parent . summariesRowList . toArray ( ) . length > 0 ;
302- const parentRowIndex = parseInt (
303- this . getClosestElemByTag ( currentRowEl , 'igx-child-grid-row' ) . parentNode . getAttribute ( 'data-rowindex' ) , 10 ) ;
304- const isLastRowInParent = parent . verticalScrollContainer . igxForOf . length - 1 === parentRowIndex ;
305- // check if next is sibling
306- const childRowContainer = this . getChildGridRowContainer ( this . grid ) ;
307- const nextIsSiblingChild = ! ! childRowContainer . nextElementSibling ;
308- if ( isLastRowInParent && parentHasSummary && ! nextIsSiblingChild ) {
309- // next is parent summary
310- const parentSummary = parent . summariesRowList . toArray ( ) [ 0 ] . nativeElement ;
311- parent . navigation . focusNextRow ( parentSummary , 0 , this . grid . rootGrid , true ) ;
312- } else {
313- // next is sibling or parent
314- this . focusNext ( 0 ) ;
315- }
316- } else if ( isLastDataRow && hasSummaries && isLastColumn && this . grid . parent ) {
301+ this . _navigateToNextParentRow ( currentRowEl ) ;
302+ } else if ( isLastDataRow && hasSummaries && isLastColumn && this . grid . parent ) {
317303 // navigating in child rows, next is child grid's summary row
318- this . focusNextRow ( summaryRows [ 0 ] . nativeElement , 0 , this . grid . parent , true ) ;
304+ this . focusNextRow ( summaryRows [ 0 ] . nativeElement , 0 , this . grid . parent , true ) ;
319305 } else {
320306 super . performTab ( currentRowEl , selectedNode ) ;
321307 }
322308 }
323309
310+ private _navigateToNextParentRow ( currentRowEl : any ) : void {
311+ // next is parent summary or next parent row
312+ const parent = this . grid . parent ;
313+ const parentHasSummary = parent . summariesRowList . length > 0 ;
314+ const parentRowIndex = parseInt (
315+ this . getClosestElemByTag ( currentRowEl , 'igx-child-grid-row' ) . parentNode . getAttribute ( 'data-rowindex' ) , 10 ) ;
316+ const isLastRowInParent = parent . verticalScrollContainer . igxForOf . length - 1 === parentRowIndex ;
317+ // check if next is sibling
318+ const childRowContainer = this . getChildGridRowContainer ( this . grid ) ;
319+ const nextIsSiblingChild = ! ! childRowContainer . nextElementSibling ;
320+ if ( isLastRowInParent && parentHasSummary && ! nextIsSiblingChild ) {
321+ // next is parent summary
322+ const parentSummary = parent . summariesRowList . first . nativeElement ;
323+ parent . navigation . focusNextRow ( parentSummary , 0 , parent , true ) ;
324+ } else {
325+ // next is sibling or parent
326+ this . focusNext ( 0 ) ;
327+ }
328+ }
329+
324330 private focusNextChildDOMElem ( currentRowEl , grid ) {
325331 const gridElem = currentRowEl . nextElementSibling . querySelector ( 'igx-hierarchical-grid' ) ;
326332 const childGridID = gridElem . getAttribute ( 'id' ) ;
@@ -443,21 +449,41 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
443449
444450 private performShiftTabIntoChild ( gridElem , currentRowEl , rowIndex ) {
445451 const childGridID = gridElem . getAttribute ( 'id' ) ;
446- const childGrid = this . getChildGrid ( childGridID , this . grid ) || this . getChildGrid ( childGridID , this . grid . parent ) ;
447- const lastIndex = childGrid . unpinnedColumns [ childGrid . unpinnedColumns . length - 1 ] . visibleIndex ;
448- const summaryRows = childGrid . summariesRowList . toArray ( ) ;
449- if ( summaryRows . length > 0 && summaryRows [ 0 ] . summaryCells . length > 0 ) {
450- // move focus to last summary row cell
451- const summaryRow = summaryRows [ 0 ] . nativeElement ;
452- this . focusPrevRow ( summaryRow , lastIndex , childGrid , true , true ) ;
453- } else if ( childGrid . rowList . toArray ( ) . length === 0 &&
454- childGrid . allowFiltering && childGrid . filterMode === FilterMode . quickFilter ) {
455- // move to filter cell
456- childGrid . navigation . moveFocusToFilterCell ( ) ;
457- } else {
458- // move to next cell
459- this . navigateUp ( currentRowEl , { row : rowIndex , column : lastIndex } ) ;
452+ const childGrid = this . getChildGrid ( childGridID , this . grid ) || this . getChildGrid ( childGridID , this . grid . parent ) ;
453+ const lastIndex = childGrid . unpinnedColumns [ childGrid . unpinnedColumns . length - 1 ] . visibleIndex ;
454+ const summaryRows = childGrid . summariesRowList . toArray ( ) ;
455+ if ( summaryRows . length > 0 && summaryRows [ 0 ] . summaryCells . length > 0 ) {
456+ // move focus to last summary row cell
457+ const summaryRow = summaryRows [ 0 ] . nativeElement ;
458+ this . focusPrevRow ( summaryRow , lastIndex , childGrid , true , true ) ;
459+ } else if ( childGrid . rowList . toArray ( ) . length === 0 &&
460+ childGrid . allowFiltering && childGrid . filterMode === FilterMode . quickFilter ) {
461+ // move to filter cell
462+ childGrid . navigation . moveFocusToFilterCell ( ) ;
463+ } else if ( childGrid . rowList . length === 0 ) {
464+ // move to prev child or parent row
465+ const prevChild = this . getSibling ( childGrid ) ;
466+ if ( prevChild ) {
467+ this . performShiftTabIntoChild ( prevChild , currentRowEl , rowIndex ) ;
468+ } else {
469+ const selNode = {
470+ row : rowIndex ,
471+ column : this . grid . unpinnedColumns [ this . grid . unpinnedColumns . length - 1 ] . visibleIndex
472+ } ;
473+ this . navigateUp ( currentRowEl , selNode ) ;
474+ }
475+ } else {
476+ // move to prev cell
477+ childGrid . navigation . goToLastCell ( ) ;
478+ }
479+ }
480+
481+ private getSibling ( childGrid ) {
482+ const prevChildRow = childGrid . childRow . nativeElement . previousElementSibling ;
483+ if ( prevChildRow ) {
484+ return prevChildRow . children [ 0 ] . children [ 0 ] ;
460485 }
486+ return null ;
461487 }
462488
463489 private focusNextChild ( elem , visibleColumnIndex , grid ) {
@@ -711,7 +737,12 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
711737 grid . parentVirtDir . onChunkLoad
712738 . pipe ( first ( ) )
713739 . subscribe ( callBackFunc ) ;
714- grid . dataRowList . toArray ( ) [ 0 ] . virtDirRow . scrollTo ( unpinnedIndex ) ;
740+ if ( grid . dataRowList . length > 0 ) {
741+ grid . dataRowList . first . virtDirRow . scrollTo ( unpinnedIndex ) ;
742+ } else {
743+ grid . headerContainer . scrollTo ( unpinnedIndex ) ;
744+ }
745+
715746 }
716747 private scrollGrid ( grid , target , callBackFunc ) {
717748 this . getFocusableGrid ( ) . nativeElement . focus ( { preventScroll : true } ) ;
0 commit comments