@@ -913,6 +913,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
913913 const maxColumnWidth = Math . max ( maxColumnWidthIn , minColumnWidth ) ;
914914 const maxColumnAutoWidth = Math . max ( maxColumnAutoWidthIn ?? maxColumnWidth , minColumnWidth ) ;
915915
916+ const freezeLeftColumns = typeof freezeColumns === "number" ? freezeColumns : freezeColumns [ 0 ] ;
917+ const freezeRightColumns = typeof freezeColumns === "number" ? 0 : freezeColumns [ 1 ] ;
918+
916919 const docStyle = React . useMemo ( ( ) => {
917920 if ( typeof window === "undefined" ) return { fontSize : "16px" } ;
918921 return window . getComputedStyle ( document . documentElement ) ;
@@ -1563,9 +1566,13 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
15631566 height : targetRect . height + 2 * paddingY ,
15641567 } ;
15651568
1566- let frozenWidth = 0 ;
1567- for ( let i = 0 ; i < freezeColumns ; i ++ ) {
1568- frozenWidth += columns [ i ] . width ;
1569+ let frozenLeftWidth = 0 ;
1570+ for ( let i = 0 ; i < freezeLeftColumns ; i ++ ) {
1571+ frozenLeftWidth += columns [ i ] . width ;
1572+ }
1573+ let frozenRightWidth = 0 ;
1574+ for ( let i = mangledCols . length - 1 ; i >= mangledCols . length - freezeRightColumns ; i -- ) {
1575+ frozenRightWidth += columns [ i ] . width ;
15691576 }
15701577 let trailingRowHeight = 0 ;
15711578 const freezeTrailingRowsEffective = freezeTrailingRows + ( lastRowSticky ? 1 : 0 ) ;
@@ -1578,8 +1585,8 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
15781585 }
15791586
15801587 // scrollBounds is already scaled
1581- let sLeft = frozenWidth * scale + scrollBounds . left + rowMarkerOffset * rowMarkerWidth * scale ;
1582- let sRight = scrollBounds . right ;
1588+ let sLeft = frozenLeftWidth * scale + scrollBounds . left + rowMarkerOffset * rowMarkerWidth * scale ;
1589+ let sRight = scrollBounds . right - frozenRightWidth * scale ;
15831590 let sTop = scrollBounds . top + totalHeaderHeight * scale ;
15841591 let sBottom = scrollBounds . bottom - trailingRowHeight * scale ;
15851592
@@ -1623,7 +1630,11 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
16231630 scrollY = bounds . y + bounds . height - sBottom ;
16241631 }
16251632
1626- if ( dir === "vertical" || ( typeof col === "number" && col < freezeColumns ) ) {
1633+ if (
1634+ dir === "vertical" ||
1635+ ( typeof col === "number" &&
1636+ ( col < freezeLeftColumns || col >= mangledCols . length - freezeRightColumns ) )
1637+ ) {
16271638 scrollX = 0 ;
16281639 } else if (
16291640 dir === "horizontal" ||
@@ -1654,7 +1665,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
16541665 rowMarkerWidth ,
16551666 scrollRef ,
16561667 totalHeaderHeight ,
1657- freezeColumns ,
1668+ freezeLeftColumns ,
1669+ freezeRightColumns ,
1670+ mangledCols . length ,
16581671 columns ,
16591672 mangledRows ,
16601673 lastRowSticky ,
@@ -2570,18 +2583,29 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
25702583 selected = [ selected [ 0 ] - rowMarkerOffset , selected [ 1 ] ] ;
25712584 }
25722585
2573- const freezeRegion =
2574- freezeColumns === 0
2586+ const freezeLeftRegion =
2587+ freezeLeftColumns === 0
25752588 ? undefined
25762589 : {
25772590 x : 0 ,
25782591 y : region . y ,
2579- width : freezeColumns ,
2592+ width : freezeLeftColumns ,
2593+ height : region . height ,
2594+ } ;
2595+
2596+ const freezeRightRegion =
2597+ freezeRightColumns === 0
2598+ ? undefined
2599+ : {
2600+ x : columns . length - freezeRightColumns ,
2601+ y : region . y ,
2602+ width : freezeRightColumns ,
25802603 height : region . height ,
25812604 } ;
25822605
25832606 const freezeRegions : Rectangle [ ] = [ ] ;
2584- if ( freezeRegion !== undefined ) freezeRegions . push ( freezeRegion ) ;
2607+ if ( freezeLeftRegion !== undefined ) freezeRegions . push ( freezeLeftRegion ) ;
2608+ if ( freezeRightRegion !== undefined ) freezeRegions . push ( freezeRightRegion ) ;
25852609 if ( freezeTrailingRows > 0 ) {
25862610 freezeRegions . push ( {
25872611 x : region . x - rowMarkerOffset ,
@@ -2590,11 +2614,20 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
25902614 height : freezeTrailingRows ,
25912615 } ) ;
25922616
2593- if ( freezeColumns > 0 ) {
2617+ if ( freezeLeftColumns > 0 ) {
25942618 freezeRegions . push ( {
25952619 x : 0 ,
25962620 y : rows - freezeTrailingRows ,
2597- width : freezeColumns ,
2621+ width : freezeLeftColumns ,
2622+ height : freezeTrailingRows ,
2623+ } ) ;
2624+ }
2625+
2626+ if ( freezeRightColumns > 0 ) {
2627+ freezeRegions . push ( {
2628+ x : columns . length - freezeRightColumns ,
2629+ y : rows - freezeTrailingRows ,
2630+ width : freezeRightColumns ,
25982631 height : freezeTrailingRows ,
25992632 } ) ;
26002633 }
@@ -2609,7 +2642,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
26092642 ty,
26102643 extras : {
26112644 selected,
2612- freezeRegion,
2645+ freezeRegion : freezeLeftRegion ,
26132646 freezeRegions,
26142647 } ,
26152648 } ;
@@ -2623,7 +2656,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
26232656 rowMarkerOffset ,
26242657 showTrailingBlankRow ,
26252658 rows ,
2626- freezeColumns ,
2659+ freezeLeftColumns ,
2660+ freezeRightColumns ,
2661+ columns . length ,
26272662 freezeTrailingRows ,
26282663 setVisibleRegion ,
26292664 onVisibleRegionChanged ,
@@ -3965,7 +4000,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
39654000 ) ;
39664001 } , [ onGroupHeaderRenamed , renameGroup ] ) ;
39674002
3968- const mangledFreezeColumns = Math . min ( mangledCols . length , freezeColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
4003+ const mangledFreezeColumns = Math . min ( mangledCols . length , freezeLeftColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
39694004
39704005 React . useImperativeHandle (
39714006 forwardedRef ,
@@ -4233,7 +4268,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
42334268 onColumnProposeMove = { onColumnProposeMoveImpl }
42344269 drawCell = { drawCell }
42354270 disabledRows = { disabledRows }
4236- freezeColumns = { mangledFreezeColumns }
4271+ freezeColumns = { [ mangledFreezeColumns , freezeRightColumns ] }
42374272 lockColumns = { rowMarkerOffset }
42384273 firstColAccessible = { rowMarkerOffset === 0 }
42394274 getCellContent = { getMangledCellContent }
0 commit comments