@@ -893,6 +893,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
893893 const maxColumnWidth = Math . max ( maxColumnWidthIn , minColumnWidth ) ;
894894 const maxColumnAutoWidth = Math . max ( maxColumnAutoWidthIn ?? maxColumnWidth , minColumnWidth ) ;
895895
896+ const freezeLeftColumns = typeof freezeColumns === "number" ? freezeColumns : freezeColumns [ 0 ] ;
897+ const freezeRightColumns = typeof freezeColumns === "number" ? 0 : freezeColumns [ 1 ] ;
898+
896899 const docStyle = React . useMemo ( ( ) => {
897900 if ( typeof window === "undefined" ) return { fontSize : "16px" } ;
898901 return window . getComputedStyle ( document . documentElement ) ;
@@ -1541,9 +1544,13 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
15411544 height : targetRect . height + 2 * paddingY ,
15421545 } ;
15431546
1544- let frozenWidth = 0 ;
1545- for ( let i = 0 ; i < freezeColumns ; i ++ ) {
1546- frozenWidth += columns [ i ] . width ;
1547+ let frozenLeftWidth = 0 ;
1548+ for ( let i = 0 ; i < freezeLeftColumns ; i ++ ) {
1549+ frozenLeftWidth += columns [ i ] . width ;
1550+ }
1551+ let frozenRightWidth = 0 ;
1552+ for ( let i = mangledCols . length - 1 ; i >= mangledCols . length - freezeRightColumns ; i -- ) {
1553+ frozenRightWidth += columns [ i ] . width ;
15471554 }
15481555 let trailingRowHeight = 0 ;
15491556 const freezeTrailingRowsEffective = freezeTrailingRows + ( lastRowSticky ? 1 : 0 ) ;
@@ -1556,8 +1563,8 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
15561563 }
15571564
15581565 // scrollBounds is already scaled
1559- let sLeft = frozenWidth * scale + scrollBounds . left + rowMarkerOffset * rowMarkerWidth * scale ;
1560- let sRight = scrollBounds . right ;
1566+ let sLeft = frozenLeftWidth * scale + scrollBounds . left + rowMarkerOffset * rowMarkerWidth * scale ;
1567+ let sRight = scrollBounds . right - frozenRightWidth * scale ;
15611568 let sTop = scrollBounds . top + totalHeaderHeight * scale ;
15621569 let sBottom = scrollBounds . bottom - trailingRowHeight * scale ;
15631570
@@ -1601,7 +1608,11 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
16011608 scrollY = bounds . y + bounds . height - sBottom ;
16021609 }
16031610
1604- if ( dir === "vertical" || ( typeof col === "number" && col < freezeColumns ) ) {
1611+ if (
1612+ dir === "vertical" ||
1613+ ( typeof col === "number" &&
1614+ ( col < freezeLeftColumns || col >= mangledCols . length - freezeRightColumns ) )
1615+ ) {
16051616 scrollX = 0 ;
16061617 } else if (
16071618 dir === "horizontal" ||
@@ -1632,7 +1643,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
16321643 rowMarkerWidth ,
16331644 scrollRef ,
16341645 totalHeaderHeight ,
1635- freezeColumns ,
1646+ freezeLeftColumns ,
1647+ freezeRightColumns ,
1648+ mangledCols . length ,
16361649 columns ,
16371650 mangledRows ,
16381651 lastRowSticky ,
@@ -2482,18 +2495,29 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
24822495 selected = [ selected [ 0 ] - rowMarkerOffset , selected [ 1 ] ] ;
24832496 }
24842497
2485- const freezeRegion =
2486- freezeColumns === 0
2498+ const freezeLeftRegion =
2499+ freezeLeftColumns === 0
24872500 ? undefined
24882501 : {
24892502 x : 0 ,
24902503 y : region . y ,
2491- width : freezeColumns ,
2504+ width : freezeLeftColumns ,
2505+ height : region . height ,
2506+ } ;
2507+
2508+ const freezeRightRegion =
2509+ freezeRightColumns === 0
2510+ ? undefined
2511+ : {
2512+ x : columns . length - freezeRightColumns ,
2513+ y : region . y ,
2514+ width : freezeRightColumns ,
24922515 height : region . height ,
24932516 } ;
24942517
24952518 const freezeRegions : Rectangle [ ] = [ ] ;
2496- if ( freezeRegion !== undefined ) freezeRegions . push ( freezeRegion ) ;
2519+ if ( freezeLeftRegion !== undefined ) freezeRegions . push ( freezeLeftRegion ) ;
2520+ if ( freezeRightRegion !== undefined ) freezeRegions . push ( freezeRightRegion ) ;
24972521 if ( freezeTrailingRows > 0 ) {
24982522 freezeRegions . push ( {
24992523 x : region . x - rowMarkerOffset ,
@@ -2502,11 +2526,20 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
25022526 height : freezeTrailingRows ,
25032527 } ) ;
25042528
2505- if ( freezeColumns > 0 ) {
2529+ if ( freezeLeftColumns > 0 ) {
25062530 freezeRegions . push ( {
25072531 x : 0 ,
25082532 y : rows - freezeTrailingRows ,
2509- width : freezeColumns ,
2533+ width : freezeLeftColumns ,
2534+ height : freezeTrailingRows ,
2535+ } ) ;
2536+ }
2537+
2538+ if ( freezeRightColumns > 0 ) {
2539+ freezeRegions . push ( {
2540+ x : columns . length - freezeRightColumns ,
2541+ y : rows - freezeTrailingRows ,
2542+ width : freezeRightColumns ,
25102543 height : freezeTrailingRows ,
25112544 } ) ;
25122545 }
@@ -2521,7 +2554,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
25212554 ty,
25222555 extras : {
25232556 selected,
2524- freezeRegion,
2557+ freezeRegion : freezeLeftRegion ,
25252558 freezeRegions,
25262559 } ,
25272560 } ;
@@ -2535,7 +2568,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
25352568 rowMarkerOffset ,
25362569 showTrailingBlankRow ,
25372570 rows ,
2538- freezeColumns ,
2571+ freezeLeftColumns ,
2572+ freezeRightColumns ,
2573+ columns . length ,
25392574 freezeTrailingRows ,
25402575 setVisibleRegion ,
25412576 onVisibleRegionChanged ,
@@ -3844,7 +3879,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
38443879 ) ;
38453880 } , [ onGroupHeaderRenamed , renameGroup ] ) ;
38463881
3847- const mangledFreezeColumns = Math . min ( mangledCols . length , freezeColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
3882+ const mangledFreezeColumns = Math . min ( mangledCols . length , freezeLeftColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
38483883
38493884 React . useImperativeHandle (
38503885 forwardedRef ,
@@ -4101,7 +4136,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
41014136 onColumnProposeMove = { onColumnProposeMoveImpl }
41024137 drawCell = { drawCell }
41034138 disabledRows = { disabledRows }
4104- freezeColumns = { mangledFreezeColumns }
4139+ freezeColumns = { [ mangledFreezeColumns , freezeRightColumns ] }
41054140 lockColumns = { rowMarkerOffset }
41064141 firstColAccessible = { rowMarkerOffset === 0 }
41074142 getCellContent = { getMangledCellContent }
0 commit comments