@@ -16,7 +16,6 @@ import GroupRowRenderer from './GroupRow';
16
16
import SummaryRow from './SummaryRow' ;
17
17
import {
18
18
assertIsValidKeyGetter ,
19
- getColumnScrollPosition ,
20
19
onEditorNavigation ,
21
20
getNextSelectedCellPosition ,
22
21
isSelectedCellEditable ,
@@ -248,7 +247,7 @@ function DataGrid<R, SR>({
248
247
const clientHeight = gridHeight - totalHeaderHeight - summaryRowsCount * rowHeight ;
249
248
const isSelectable = selectedRows !== undefined && onSelectedRowsChange !== undefined ;
250
249
251
- const { columns, viewportColumns, totalColumnWidth, lastFrozenColumnIndex, totalFrozenColumnWidth, groupBy } = useViewportColumns ( {
250
+ const { columns, viewportColumns, layoutCssVars , columnMetrics , totalColumnWidth, lastFrozenColumnIndex, totalFrozenColumnWidth, groupBy } = useViewportColumns ( {
252
251
rawColumns,
253
252
columnWidths,
254
253
scrollLeft,
@@ -637,12 +636,13 @@ function DataGrid<R, SR>({
637
636
638
637
if ( typeof idx === 'number' && idx > lastFrozenColumnIndex ) {
639
638
const { clientWidth } = current ;
640
- const { left, width } = columns [ idx ] ;
641
- const isCellAtLeftBoundary = left < scrollLeft + width + totalFrozenColumnWidth ;
639
+ const { left, width } = columnMetrics . get ( columns [ idx ] ) ! ;
640
+ const isCellAtLeftBoundary = left < scrollLeft + totalFrozenColumnWidth ;
642
641
const isCellAtRightBoundary = left + width > clientWidth + scrollLeft ;
643
- if ( isCellAtLeftBoundary || isCellAtRightBoundary ) {
644
- const newScrollLeft = getColumnScrollPosition ( columns , idx , scrollLeft , clientWidth ) ;
645
- current . scrollLeft = scrollLeft + newScrollLeft ;
642
+ if ( isCellAtLeftBoundary ) {
643
+ current . scrollLeft = left - totalFrozenColumnWidth ;
644
+ } else if ( isCellAtRightBoundary ) {
645
+ current . scrollLeft = left + width - clientWidth ;
646
646
}
647
647
}
648
648
@@ -884,7 +884,8 @@ function DataGrid<R, SR>({
884
884
'--header-row-height' : `${ headerRowHeight } px` ,
885
885
'--filter-row-height' : `${ headerFiltersHeight } px` ,
886
886
'--row-width' : `${ totalColumnWidth } px` ,
887
- '--row-height' : `${ rowHeight } px`
887
+ '--row-height' : `${ rowHeight } px` ,
888
+ ...layoutCssVars
888
889
} as unknown as React . CSSProperties }
889
890
ref = { gridRef }
890
891
onScroll = { handleScroll }
0 commit comments