@@ -493,18 +493,21 @@ function TableBody({
493
493
const viewportHeight = viewport . offsetHeight ;
494
494
const rowElement = rowRefs . current [ focusIndex ] ;
495
495
const rowRect = rowElement . getBoundingClientRect ( ) ;
496
- const parentRect = bodyRef . current . getBoundingClientRect ( ) ;
496
+ const parentRect = viewport . getBoundingClientRect ( ) ;
497
497
const viewportScrollTop = viewport . scrollTop ;
498
-
499
- const rowTopRelativeToViewport = rowRect . top - parentRect . top ;
500
- const rowBottomRelativeToViewport = rowRect . bottom - parentRect . top ;
501
-
502
- if ( rowTopRelativeToViewport < viewportScrollTop ) {
498
+ const rowTopRelativeToViewport = rowRect . top - parentRect . top + viewport . scrollTop ;
499
+ const rowBottomRelativeToViewport = rowRect . bottom - parentRect . top + viewport . scrollTop ;
500
+ if ( rowTopRelativeToViewport - 30 < viewportScrollTop ) {
503
501
// Row is above the visible area
504
- viewport . scrollTo ( { top : rowTopRelativeToViewport } ) ;
505
- } else if ( rowBottomRelativeToViewport > viewportScrollTop + viewportHeight ) {
502
+ let topVal = rowTopRelativeToViewport - 30 ;
503
+ if ( topVal < 0 ) {
504
+ topVal = 0 ;
505
+ }
506
+ viewport . scrollTo ( { top : topVal } ) ;
507
+ } else if ( rowBottomRelativeToViewport + 5 > viewportScrollTop + viewportHeight ) {
506
508
// Row is below the visible area
507
- viewport . scrollTo ( { top : rowBottomRelativeToViewport - viewportHeight } ) ;
509
+ const topVal = rowBottomRelativeToViewport - viewportHeight + 5 ;
510
+ viewport . scrollTo ( { top : topVal } ) ;
508
511
}
509
512
}
510
513
// setIndexChangedFromClick(false);
@@ -772,6 +775,14 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
772
775
setFocusIndex ( ( idx ) => Math . min ( idx + 1 , filteredData . length - 1 ) ) ;
773
776
return true ;
774
777
}
778
+ if ( checkKeyPressed ( waveEvent , "PageUp" ) ) {
779
+ setFocusIndex ( ( idx ) => Math . max ( idx - 20 , 0 ) ) ;
780
+ return true ;
781
+ }
782
+ if ( checkKeyPressed ( waveEvent , "PageDown" ) ) {
783
+ setFocusIndex ( ( idx ) => Math . min ( idx + 20 , filteredData . length - 1 ) ) ;
784
+ return true ;
785
+ }
775
786
if ( checkKeyPressed ( waveEvent , "Enter" ) ) {
776
787
if ( filteredData . length == 0 ) {
777
788
return ;
0 commit comments