@@ -913,6 +913,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
913
913
const maxColumnWidth = Math . max ( maxColumnWidthIn , minColumnWidth ) ;
914
914
const maxColumnAutoWidth = Math . max ( maxColumnAutoWidthIn ?? maxColumnWidth , minColumnWidth ) ;
915
915
916
+ const freezeLeftColumns = typeof freezeColumns === "number" ? freezeColumns : freezeColumns [ 0 ] ;
917
+ const freezeRightColumns = typeof freezeColumns === "number" ? 0 : freezeColumns [ 1 ] ;
918
+
916
919
const docStyle = React . useMemo ( ( ) => {
917
920
if ( typeof window === "undefined" ) return { fontSize : "16px" } ;
918
921
return window . getComputedStyle ( document . documentElement ) ;
@@ -1563,9 +1566,13 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1563
1566
height : targetRect . height + 2 * paddingY ,
1564
1567
} ;
1565
1568
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 ;
1569
1576
}
1570
1577
let trailingRowHeight = 0 ;
1571
1578
const freezeTrailingRowsEffective = freezeTrailingRows + ( lastRowSticky ? 1 : 0 ) ;
@@ -1578,8 +1585,8 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1578
1585
}
1579
1586
1580
1587
// 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 ;
1583
1590
let sTop = scrollBounds . top + totalHeaderHeight * scale ;
1584
1591
let sBottom = scrollBounds . bottom - trailingRowHeight * scale ;
1585
1592
@@ -1623,7 +1630,11 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1623
1630
scrollY = bounds . y + bounds . height - sBottom ;
1624
1631
}
1625
1632
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
+ ) {
1627
1638
scrollX = 0 ;
1628
1639
} else if (
1629
1640
dir === "horizontal" ||
@@ -1654,7 +1665,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1654
1665
rowMarkerWidth ,
1655
1666
scrollRef ,
1656
1667
totalHeaderHeight ,
1657
- freezeColumns ,
1668
+ freezeLeftColumns ,
1669
+ freezeRightColumns ,
1670
+ mangledCols . length ,
1658
1671
columns ,
1659
1672
mangledRows ,
1660
1673
lastRowSticky ,
@@ -2570,18 +2583,29 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2570
2583
selected = [ selected [ 0 ] - rowMarkerOffset , selected [ 1 ] ] ;
2571
2584
}
2572
2585
2573
- const freezeRegion =
2574
- freezeColumns === 0
2586
+ const freezeLeftRegion =
2587
+ freezeLeftColumns === 0
2575
2588
? undefined
2576
2589
: {
2577
2590
x : 0 ,
2578
2591
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 ,
2580
2603
height : region . height ,
2581
2604
} ;
2582
2605
2583
2606
const freezeRegions : Rectangle [ ] = [ ] ;
2584
- if ( freezeRegion !== undefined ) freezeRegions . push ( freezeRegion ) ;
2607
+ if ( freezeLeftRegion !== undefined ) freezeRegions . push ( freezeLeftRegion ) ;
2608
+ if ( freezeRightRegion !== undefined ) freezeRegions . push ( freezeRightRegion ) ;
2585
2609
if ( freezeTrailingRows > 0 ) {
2586
2610
freezeRegions . push ( {
2587
2611
x : region . x - rowMarkerOffset ,
@@ -2590,11 +2614,20 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2590
2614
height : freezeTrailingRows ,
2591
2615
} ) ;
2592
2616
2593
- if ( freezeColumns > 0 ) {
2617
+ if ( freezeLeftColumns > 0 ) {
2594
2618
freezeRegions . push ( {
2595
2619
x : 0 ,
2596
2620
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 ,
2598
2631
height : freezeTrailingRows ,
2599
2632
} ) ;
2600
2633
}
@@ -2609,7 +2642,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2609
2642
ty,
2610
2643
extras : {
2611
2644
selected,
2612
- freezeRegion,
2645
+ freezeRegion : freezeLeftRegion ,
2613
2646
freezeRegions,
2614
2647
} ,
2615
2648
} ;
@@ -2623,7 +2656,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2623
2656
rowMarkerOffset ,
2624
2657
showTrailingBlankRow ,
2625
2658
rows ,
2626
- freezeColumns ,
2659
+ freezeLeftColumns ,
2660
+ freezeRightColumns ,
2661
+ columns . length ,
2627
2662
freezeTrailingRows ,
2628
2663
setVisibleRegion ,
2629
2664
onVisibleRegionChanged ,
@@ -3965,7 +4000,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
3965
4000
) ;
3966
4001
} , [ onGroupHeaderRenamed , renameGroup ] ) ;
3967
4002
3968
- const mangledFreezeColumns = Math . min ( mangledCols . length , freezeColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
4003
+ const mangledFreezeColumns = Math . min ( mangledCols . length , freezeLeftColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
3969
4004
3970
4005
React . useImperativeHandle (
3971
4006
forwardedRef ,
@@ -4233,7 +4268,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
4233
4268
onColumnProposeMove = { onColumnProposeMoveImpl }
4234
4269
drawCell = { drawCell }
4235
4270
disabledRows = { disabledRows }
4236
- freezeColumns = { mangledFreezeColumns }
4271
+ freezeColumns = { [ mangledFreezeColumns , freezeRightColumns ] }
4237
4272
lockColumns = { rowMarkerOffset }
4238
4273
firstColAccessible = { rowMarkerOffset === 0 }
4239
4274
getCellContent = { getMangledCellContent }
0 commit comments