@@ -333,6 +333,13 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
333
333
} ) ;
334
334
}
335
335
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
+
336
343
@HostListener ( 'dblclick' , [ '$event' ] )
337
344
public onDoubleClick ( event ) {
338
345
if ( this . column . editable ) {
@@ -589,16 +596,14 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
589
596
&& verticalScroll . scrollTop // the scrollbar is not at the first item
590
597
&& target . row . element . nativeElement . offsetTop < this . grid . rowHeight ) { // the target is in the first row
591
598
592
- this . grid . verticalScrollContainer . addScrollTop ( - this . grid . rowHeight ) ;
593
- this . _focusNextCell ( rowIndex , this . visibleColumnIndex ) ;
599
+ this . performVerticalScroll ( - this . grid . rowHeight , rowIndex ) ;
594
600
}
595
601
target . nativeElement . focus ( ) ;
596
602
} else {
597
603
const scrollOffset =
598
604
- parseInt ( this . grid . verticalScrollContainer . dc . instance . _viewContainer . element . nativeElement . style . top , 10 ) ;
599
605
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 ) ;
602
607
}
603
608
}
604
609
@@ -626,20 +631,17 @@ export class IgxGridCellComponent implements IGridBus, OnInit, OnDestroy, AfterV
626
631
const targetEndTopOffset = target . row . element . nativeElement . offsetTop + this . grid . rowHeight + containerTopOffset ;
627
632
if ( containerHeight && targetEndTopOffset > containerHeight ) {
628
633
const scrollAmount = targetEndTopOffset - containerHeight ;
629
- this . grid . verticalScrollContainer . addScrollTop ( scrollAmount ) ;
630
-
631
- this . _focusNextCell ( rowIndex , this . visibleColumnIndex ) ;
634
+ this . performVerticalScroll ( scrollAmount , rowIndex ) ;
632
635
} else {
633
636
target . nativeElement . focus ( ) ;
634
637
}
635
638
} else {
636
- const containerHeight = this . grid . calcHeight ;
637
639
const contentHeight = this . grid . verticalScrollContainer . dc . instance . _viewContainer . element . nativeElement . offsetHeight ;
638
640
const scrollOffset = parseInt ( this . grid . verticalScrollContainer . dc . instance . _viewContainer . element . nativeElement . style . top , 10 ) ;
639
641
const lastRowOffset = contentHeight + scrollOffset - this . grid . calcHeight ;
640
642
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 ) ;
643
645
}
644
646
}
645
647
0 commit comments