@@ -333,6 +333,13 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
333333 } ) ;
334334 }
335335
336+ private performVerticalScroll ( amout : number , rowIndex : number ) {
337+ const scrolled = this . grid . verticalScrollContainer . addScrollTop ( amout ) ;
338+ if ( scrolled ) {
339+ this . _focusNextCell ( rowIndex , this . visibleColumnIndex ) ;
340+ }
341+ }
342+
336343 @HostListener ( 'dblclick' , [ '$event' ] )
337344 public onDoubleClick ( event ) {
338345 if ( this . column . editable ) {
@@ -589,16 +596,14 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
589596 && verticalScroll . scrollTop // the scrollbar is not at the first item
590597 && target . row . element . nativeElement . offsetTop < this . grid . rowHeight ) { // the target is in the first row
591598
592- this . grid . verticalScrollContainer . addScrollTop ( - this . grid . rowHeight ) ;
593- this . _focusNextCell ( rowIndex , this . visibleColumnIndex ) ;
599+ this . performVerticalScroll ( - this . grid . rowHeight , rowIndex ) ;
594600 }
595601 target . nativeElement . focus ( ) ;
596602 } else {
597603 const scrollOffset =
598604 - parseInt ( this . grid . verticalScrollContainer . dc . instance . _viewContainer . element . nativeElement . style . top , 10 ) ;
599605 const scrollAmount = this . grid . rowHeight + scrollOffset ;
600- this . grid . verticalScrollContainer . addScrollTop ( - scrollAmount ) ;
601- this . _focusNextCell ( this . rowIndex , this . visibleColumnIndex ) ;
606+ this . performVerticalScroll ( - scrollAmount , this . rowIndex ) ;
602607 }
603608 }
604609
@@ -626,20 +631,17 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
626631 const targetEndTopOffset = target . row . element . nativeElement . offsetTop + this . grid . rowHeight + containerTopOffset ;
627632 if ( containerHeight && targetEndTopOffset > containerHeight ) {
628633 const scrollAmount = targetEndTopOffset - containerHeight ;
629- this . grid . verticalScrollContainer . addScrollTop ( scrollAmount ) ;
630-
631- this . _focusNextCell ( rowIndex , this . visibleColumnIndex ) ;
634+ this . performVerticalScroll ( scrollAmount , rowIndex ) ;
632635 } else {
633636 target . nativeElement . focus ( ) ;
634637 }
635638 } else {
636- const containerHeight = this . grid . calcHeight ;
637639 const contentHeight = this . grid . verticalScrollContainer . dc . instance . _viewContainer . element . nativeElement . offsetHeight ;
638640 const scrollOffset = parseInt ( this . grid . verticalScrollContainer . dc . instance . _viewContainer . element . nativeElement . style . top , 10 ) ;
639641 const lastRowOffset = contentHeight + scrollOffset - this . grid . calcHeight ;
640642 const scrollAmount = this . grid . rowHeight + lastRowOffset ;
641- this . grid . verticalScrollContainer . addScrollTop ( scrollAmount ) ;
642- this . _focusNextCell ( this . rowIndex , this . visibleColumnIndex ) ;
643+
644+ this . performVerticalScroll ( scrollAmount , this . rowIndex ) ;
643645 }
644646 }
645647
0 commit comments