@@ -660,6 +660,11 @@ export interface DataEditorProps extends Props, Pick<DataGridSearchProps, "image
660
660
* Allows overriding the default amount of bloom (the size growth of the overlay editor)
661
661
*/
662
662
readonly editorBloom ?: readonly [ number , number ] ;
663
+
664
+ /**
665
+ * If set to true, the data grid will attempt to scroll to keep the selction in view
666
+ */
667
+ readonly scrollToActiveCell ?: boolean ;
663
668
}
664
669
665
670
type ScrollToFn = (
@@ -847,6 +852,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
847
852
isOutsideClick,
848
853
renderers,
849
854
resizeIndicator,
855
+ scrollToActiveCell = true ,
850
856
} = p ;
851
857
852
858
const rowMarkersObj = typeof p . rowMarkers === "string" ? undefined : p . rowMarkers ;
@@ -2843,6 +2849,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2843
2849
]
2844
2850
) ;
2845
2851
2852
+ const scrollToActiveCellRef = React . useRef ( scrollToActiveCell ) ;
2853
+ scrollToActiveCellRef . current = scrollToActiveCell ;
2854
+
2846
2855
const updateSelectedCell = React . useCallback (
2847
2856
( col : number , row : number , fromEditingTrailingRow : boolean , freeMove : boolean ) : boolean => {
2848
2857
const rowMax = mangledRows - ( fromEditingTrailingRow ? 0 : 1 ) ;
@@ -2885,7 +2894,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2885
2894
lastSent . current = undefined ;
2886
2895
}
2887
2896
2888
- scrollTo ( col - rowMarkerOffset , row ) ;
2897
+ if ( scrollToActiveCellRef . current ) {
2898
+ scrollTo ( col - rowMarkerOffset , row ) ;
2899
+ }
2889
2900
2890
2901
return true ;
2891
2902
} ,
@@ -3720,6 +3731,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
3720
3731
scrollToRef . current = scrollTo ;
3721
3732
React . useLayoutEffect ( ( ) => {
3722
3733
if (
3734
+ scrollToActiveCellRef . current &&
3723
3735
! hasJustScrolled . current &&
3724
3736
outCol !== undefined &&
3725
3737
outRow !== undefined &&
0 commit comments