@@ -893,6 +893,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
893
893
const maxColumnWidth = Math . max ( maxColumnWidthIn , minColumnWidth ) ;
894
894
const maxColumnAutoWidth = Math . max ( maxColumnAutoWidthIn ?? maxColumnWidth , minColumnWidth ) ;
895
895
896
+ const freezeLeftColumns = typeof freezeColumns === "number" ? freezeColumns : freezeColumns [ 0 ] ;
897
+ const freezeRightColumns = typeof freezeColumns === "number" ? 0 : freezeColumns [ 1 ] ;
898
+
896
899
const docStyle = React . useMemo ( ( ) => {
897
900
if ( typeof window === "undefined" ) return { fontSize : "16px" } ;
898
901
return window . getComputedStyle ( document . documentElement ) ;
@@ -1541,9 +1544,13 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1541
1544
height : targetRect . height + 2 * paddingY ,
1542
1545
} ;
1543
1546
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 ;
1547
1554
}
1548
1555
let trailingRowHeight = 0 ;
1549
1556
const freezeTrailingRowsEffective = freezeTrailingRows + ( lastRowSticky ? 1 : 0 ) ;
@@ -1556,8 +1563,8 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1556
1563
}
1557
1564
1558
1565
// 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 ;
1561
1568
let sTop = scrollBounds . top + totalHeaderHeight * scale ;
1562
1569
let sBottom = scrollBounds . bottom - trailingRowHeight * scale ;
1563
1570
@@ -1601,7 +1608,11 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1601
1608
scrollY = bounds . y + bounds . height - sBottom ;
1602
1609
}
1603
1610
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
+ ) {
1605
1616
scrollX = 0 ;
1606
1617
} else if (
1607
1618
dir === "horizontal" ||
@@ -1632,7 +1643,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1632
1643
rowMarkerWidth ,
1633
1644
scrollRef ,
1634
1645
totalHeaderHeight ,
1635
- freezeColumns ,
1646
+ freezeLeftColumns ,
1647
+ freezeRightColumns ,
1648
+ mangledCols . length ,
1636
1649
columns ,
1637
1650
mangledRows ,
1638
1651
lastRowSticky ,
@@ -2482,18 +2495,29 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2482
2495
selected = [ selected [ 0 ] - rowMarkerOffset , selected [ 1 ] ] ;
2483
2496
}
2484
2497
2485
- const freezeRegion =
2486
- freezeColumns === 0
2498
+ const freezeLeftRegion =
2499
+ freezeLeftColumns === 0
2487
2500
? undefined
2488
2501
: {
2489
2502
x : 0 ,
2490
2503
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 ,
2492
2515
height : region . height ,
2493
2516
} ;
2494
2517
2495
2518
const freezeRegions : Rectangle [ ] = [ ] ;
2496
- if ( freezeRegion !== undefined ) freezeRegions . push ( freezeRegion ) ;
2519
+ if ( freezeLeftRegion !== undefined ) freezeRegions . push ( freezeLeftRegion ) ;
2520
+ if ( freezeRightRegion !== undefined ) freezeRegions . push ( freezeRightRegion ) ;
2497
2521
if ( freezeTrailingRows > 0 ) {
2498
2522
freezeRegions . push ( {
2499
2523
x : region . x - rowMarkerOffset ,
@@ -2502,11 +2526,20 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2502
2526
height : freezeTrailingRows ,
2503
2527
} ) ;
2504
2528
2505
- if ( freezeColumns > 0 ) {
2529
+ if ( freezeLeftColumns > 0 ) {
2506
2530
freezeRegions . push ( {
2507
2531
x : 0 ,
2508
2532
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 ,
2510
2543
height : freezeTrailingRows ,
2511
2544
} ) ;
2512
2545
}
@@ -2521,7 +2554,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2521
2554
ty,
2522
2555
extras : {
2523
2556
selected,
2524
- freezeRegion,
2557
+ freezeRegion : freezeLeftRegion ,
2525
2558
freezeRegions,
2526
2559
} ,
2527
2560
} ;
@@ -2535,7 +2568,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2535
2568
rowMarkerOffset ,
2536
2569
showTrailingBlankRow ,
2537
2570
rows ,
2538
- freezeColumns ,
2571
+ freezeLeftColumns ,
2572
+ freezeRightColumns ,
2573
+ columns . length ,
2539
2574
freezeTrailingRows ,
2540
2575
setVisibleRegion ,
2541
2576
onVisibleRegionChanged ,
@@ -3844,7 +3879,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
3844
3879
) ;
3845
3880
} , [ onGroupHeaderRenamed , renameGroup ] ) ;
3846
3881
3847
- const mangledFreezeColumns = Math . min ( mangledCols . length , freezeColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
3882
+ const mangledFreezeColumns = Math . min ( mangledCols . length , freezeLeftColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
3848
3883
3849
3884
React . useImperativeHandle (
3850
3885
forwardedRef ,
@@ -4101,7 +4136,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
4101
4136
onColumnProposeMove = { onColumnProposeMoveImpl }
4102
4137
drawCell = { drawCell }
4103
4138
disabledRows = { disabledRows }
4104
- freezeColumns = { mangledFreezeColumns }
4139
+ freezeColumns = { [ mangledFreezeColumns , freezeRightColumns ] }
4105
4140
lockColumns = { rowMarkerOffset }
4106
4141
firstColAccessible = { rowMarkerOffset === 0 }
4107
4142
getCellContent = { getMangledCellContent }
0 commit comments