@@ -894,6 +894,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
894
894
const maxColumnWidth = Math . max ( maxColumnWidthIn , minColumnWidth ) ;
895
895
const maxColumnAutoWidth = Math . max ( maxColumnAutoWidthIn ?? maxColumnWidth , minColumnWidth ) ;
896
896
897
+ const freezeLeftColumns = typeof freezeColumns === "number" ? freezeColumns : freezeColumns [ 0 ] ;
898
+ const freezeRightColumns = typeof freezeColumns === "number" ? 0 : freezeColumns [ 1 ] ;
899
+
897
900
const docStyle = React . useMemo ( ( ) => {
898
901
if ( typeof window === "undefined" ) return { fontSize : "16px" } ;
899
902
return window . getComputedStyle ( document . documentElement ) ;
@@ -1542,9 +1545,13 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1542
1545
height : targetRect . height + 2 * paddingY ,
1543
1546
} ;
1544
1547
1545
- let frozenWidth = 0 ;
1546
- for ( let i = 0 ; i < freezeColumns ; i ++ ) {
1547
- frozenWidth += columns [ i ] . width ;
1548
+ let frozenLeftWidth = 0 ;
1549
+ for ( let i = 0 ; i < freezeLeftColumns ; i ++ ) {
1550
+ frozenLeftWidth += columns [ i ] . width ;
1551
+ }
1552
+ let frozenRightWidth = 0 ;
1553
+ for ( let i = mangledCols . length - 1 ; i >= mangledCols . length - freezeRightColumns ; i -- ) {
1554
+ frozenRightWidth += columns [ i ] . width ;
1548
1555
}
1549
1556
let trailingRowHeight = 0 ;
1550
1557
const freezeTrailingRowsEffective = freezeTrailingRows + ( lastRowSticky ? 1 : 0 ) ;
@@ -1557,8 +1564,8 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1557
1564
}
1558
1565
1559
1566
// scrollBounds is already scaled
1560
- let sLeft = frozenWidth * scale + scrollBounds . left + rowMarkerOffset * rowMarkerWidth * scale ;
1561
- let sRight = scrollBounds . right ;
1567
+ let sLeft = frozenLeftWidth * scale + scrollBounds . left + rowMarkerOffset * rowMarkerWidth * scale ;
1568
+ let sRight = scrollBounds . right - frozenRightWidth * scale ;
1562
1569
let sTop = scrollBounds . top + totalHeaderHeight * scale ;
1563
1570
let sBottom = scrollBounds . bottom - trailingRowHeight * scale ;
1564
1571
@@ -1602,7 +1609,11 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1602
1609
scrollY = bounds . y + bounds . height - sBottom ;
1603
1610
}
1604
1611
1605
- if ( dir === "vertical" || ( typeof col === "number" && col < freezeColumns ) ) {
1612
+ if (
1613
+ dir === "vertical" ||
1614
+ ( typeof col === "number" &&
1615
+ ( col < freezeLeftColumns || col >= mangledCols . length - freezeRightColumns ) )
1616
+ ) {
1606
1617
scrollX = 0 ;
1607
1618
} else if (
1608
1619
dir === "horizontal" ||
@@ -1633,7 +1644,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1633
1644
rowMarkerWidth ,
1634
1645
scrollRef ,
1635
1646
totalHeaderHeight ,
1636
- freezeColumns ,
1647
+ freezeLeftColumns ,
1648
+ freezeRightColumns ,
1649
+ mangledCols . length ,
1637
1650
columns ,
1638
1651
mangledRows ,
1639
1652
lastRowSticky ,
@@ -2483,18 +2496,29 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2483
2496
selected = [ selected [ 0 ] - rowMarkerOffset , selected [ 1 ] ] ;
2484
2497
}
2485
2498
2486
- const freezeRegion =
2487
- freezeColumns === 0
2499
+ const freezeLeftRegion =
2500
+ freezeLeftColumns === 0
2488
2501
? undefined
2489
2502
: {
2490
2503
x : 0 ,
2491
2504
y : region . y ,
2492
- width : freezeColumns ,
2505
+ width : freezeLeftColumns ,
2506
+ height : region . height ,
2507
+ } ;
2508
+
2509
+ const freezeRightRegion =
2510
+ freezeRightColumns === 0
2511
+ ? undefined
2512
+ : {
2513
+ x : columns . length - freezeRightColumns ,
2514
+ y : region . y ,
2515
+ width : freezeRightColumns ,
2493
2516
height : region . height ,
2494
2517
} ;
2495
2518
2496
2519
const freezeRegions : Rectangle [ ] = [ ] ;
2497
- if ( freezeRegion !== undefined ) freezeRegions . push ( freezeRegion ) ;
2520
+ if ( freezeLeftRegion !== undefined ) freezeRegions . push ( freezeLeftRegion ) ;
2521
+ if ( freezeRightRegion !== undefined ) freezeRegions . push ( freezeRightRegion ) ;
2498
2522
if ( freezeTrailingRows > 0 ) {
2499
2523
freezeRegions . push ( {
2500
2524
x : region . x - rowMarkerOffset ,
@@ -2503,11 +2527,20 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2503
2527
height : freezeTrailingRows ,
2504
2528
} ) ;
2505
2529
2506
- if ( freezeColumns > 0 ) {
2530
+ if ( freezeLeftColumns > 0 ) {
2507
2531
freezeRegions . push ( {
2508
2532
x : 0 ,
2509
2533
y : rows - freezeTrailingRows ,
2510
- width : freezeColumns ,
2534
+ width : freezeLeftColumns ,
2535
+ height : freezeTrailingRows ,
2536
+ } ) ;
2537
+ }
2538
+
2539
+ if ( freezeRightColumns > 0 ) {
2540
+ freezeRegions . push ( {
2541
+ x : columns . length - freezeRightColumns ,
2542
+ y : rows - freezeTrailingRows ,
2543
+ width : freezeRightColumns ,
2511
2544
height : freezeTrailingRows ,
2512
2545
} ) ;
2513
2546
}
@@ -2522,7 +2555,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2522
2555
ty,
2523
2556
extras : {
2524
2557
selected,
2525
- freezeRegion,
2558
+ freezeRegion : freezeLeftRegion ,
2526
2559
freezeRegions,
2527
2560
} ,
2528
2561
} ;
@@ -2536,7 +2569,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2536
2569
rowMarkerOffset ,
2537
2570
showTrailingBlankRow ,
2538
2571
rows ,
2539
- freezeColumns ,
2572
+ freezeLeftColumns ,
2573
+ freezeRightColumns ,
2574
+ columns . length ,
2540
2575
freezeTrailingRows ,
2541
2576
setVisibleRegion ,
2542
2577
onVisibleRegionChanged ,
@@ -3850,7 +3885,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
3850
3885
) ;
3851
3886
} , [ onGroupHeaderRenamed , renameGroup ] ) ;
3852
3887
3853
- const mangledFreezeColumns = Math . min ( mangledCols . length , freezeColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
3888
+ const mangledFreezeColumns = Math . min ( mangledCols . length , freezeLeftColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
3854
3889
3855
3890
React . useImperativeHandle (
3856
3891
forwardedRef ,
@@ -4107,7 +4142,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
4107
4142
onColumnProposeMove = { onColumnProposeMoveImpl }
4108
4143
drawCell = { drawCell }
4109
4144
disabledRows = { disabledRows }
4110
- freezeColumns = { mangledFreezeColumns }
4145
+ freezeColumns = { [ mangledFreezeColumns , freezeRightColumns ] }
4111
4146
lockColumns = { rowMarkerOffset }
4112
4147
firstColAccessible = { rowMarkerOffset === 0 }
4113
4148
getCellContent = { getMangledCellContent }
0 commit comments