@@ -911,6 +911,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
911
911
const maxColumnWidth = Math . max ( maxColumnWidthIn , minColumnWidth ) ;
912
912
const maxColumnAutoWidth = Math . max ( maxColumnAutoWidthIn ?? maxColumnWidth , minColumnWidth ) ;
913
913
914
+ const freezeLeftColumns = typeof freezeColumns === "number" ? freezeColumns : freezeColumns [ 0 ] ;
915
+ const freezeRightColumns = typeof freezeColumns === "number" ? 0 : freezeColumns [ 1 ] ;
916
+
914
917
const docStyle = React . useMemo ( ( ) => {
915
918
if ( typeof window === "undefined" ) return { fontSize : "16px" } ;
916
919
return window . getComputedStyle ( document . documentElement ) ;
@@ -1559,9 +1562,13 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1559
1562
height : targetRect . height + 2 * paddingY ,
1560
1563
} ;
1561
1564
1562
- let frozenWidth = 0 ;
1563
- for ( let i = 0 ; i < freezeColumns ; i ++ ) {
1564
- frozenWidth += columns [ i ] . width ;
1565
+ let frozenLeftWidth = 0 ;
1566
+ for ( let i = 0 ; i < freezeLeftColumns ; i ++ ) {
1567
+ frozenLeftWidth += columns [ i ] . width ;
1568
+ }
1569
+ let frozenRightWidth = 0 ;
1570
+ for ( let i = mangledCols . length - 1 ; i >= mangledCols . length - freezeRightColumns ; i -- ) {
1571
+ frozenRightWidth += columns [ i ] . width ;
1565
1572
}
1566
1573
let trailingRowHeight = 0 ;
1567
1574
const freezeTrailingRowsEffective = freezeTrailingRows + ( lastRowSticky ? 1 : 0 ) ;
@@ -1574,8 +1581,8 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1574
1581
}
1575
1582
1576
1583
// scrollBounds is already scaled
1577
- let sLeft = frozenWidth * scale + scrollBounds . left + rowMarkerOffset * rowMarkerWidth * scale ;
1578
- let sRight = scrollBounds . right ;
1584
+ let sLeft = frozenLeftWidth * scale + scrollBounds . left + rowMarkerOffset * rowMarkerWidth * scale ;
1585
+ let sRight = scrollBounds . right - frozenRightWidth * scale ;
1579
1586
let sTop = scrollBounds . top + totalHeaderHeight * scale ;
1580
1587
let sBottom = scrollBounds . bottom - trailingRowHeight * scale ;
1581
1588
@@ -1619,7 +1626,11 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1619
1626
scrollY = bounds . y + bounds . height - sBottom ;
1620
1627
}
1621
1628
1622
- if ( dir === "vertical" || ( typeof col === "number" && col < freezeColumns ) ) {
1629
+ if (
1630
+ dir === "vertical" ||
1631
+ ( typeof col === "number" &&
1632
+ ( col < freezeLeftColumns || col >= mangledCols . length - freezeRightColumns ) )
1633
+ ) {
1623
1634
scrollX = 0 ;
1624
1635
} else if (
1625
1636
dir === "horizontal" ||
@@ -1650,7 +1661,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
1650
1661
rowMarkerWidth ,
1651
1662
scrollRef ,
1652
1663
totalHeaderHeight ,
1653
- freezeColumns ,
1664
+ freezeLeftColumns ,
1665
+ freezeRightColumns ,
1666
+ mangledCols . length ,
1654
1667
columns ,
1655
1668
mangledRows ,
1656
1669
lastRowSticky ,
@@ -2557,18 +2570,29 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2557
2570
selected = [ selected [ 0 ] - rowMarkerOffset , selected [ 1 ] ] ;
2558
2571
}
2559
2572
2560
- const freezeRegion =
2561
- freezeColumns === 0
2573
+ const freezeLeftRegion =
2574
+ freezeLeftColumns === 0
2562
2575
? undefined
2563
2576
: {
2564
2577
x : 0 ,
2565
2578
y : region . y ,
2566
- width : freezeColumns ,
2579
+ width : freezeLeftColumns ,
2580
+ height : region . height ,
2581
+ } ;
2582
+
2583
+ const freezeRightRegion =
2584
+ freezeRightColumns === 0
2585
+ ? undefined
2586
+ : {
2587
+ x : columns . length - freezeRightColumns ,
2588
+ y : region . y ,
2589
+ width : freezeRightColumns ,
2567
2590
height : region . height ,
2568
2591
} ;
2569
2592
2570
2593
const freezeRegions : Rectangle [ ] = [ ] ;
2571
- if ( freezeRegion !== undefined ) freezeRegions . push ( freezeRegion ) ;
2594
+ if ( freezeLeftRegion !== undefined ) freezeRegions . push ( freezeLeftRegion ) ;
2595
+ if ( freezeRightRegion !== undefined ) freezeRegions . push ( freezeRightRegion ) ;
2572
2596
if ( freezeTrailingRows > 0 ) {
2573
2597
freezeRegions . push ( {
2574
2598
x : region . x - rowMarkerOffset ,
@@ -2577,11 +2601,20 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2577
2601
height : freezeTrailingRows ,
2578
2602
} ) ;
2579
2603
2580
- if ( freezeColumns > 0 ) {
2604
+ if ( freezeLeftColumns > 0 ) {
2581
2605
freezeRegions . push ( {
2582
2606
x : 0 ,
2583
2607
y : rows - freezeTrailingRows ,
2584
- width : freezeColumns ,
2608
+ width : freezeLeftColumns ,
2609
+ height : freezeTrailingRows ,
2610
+ } ) ;
2611
+ }
2612
+
2613
+ if ( freezeRightColumns > 0 ) {
2614
+ freezeRegions . push ( {
2615
+ x : columns . length - freezeRightColumns ,
2616
+ y : rows - freezeTrailingRows ,
2617
+ width : freezeRightColumns ,
2585
2618
height : freezeTrailingRows ,
2586
2619
} ) ;
2587
2620
}
@@ -2596,7 +2629,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2596
2629
ty,
2597
2630
extras : {
2598
2631
selected,
2599
- freezeRegion,
2632
+ freezeRegion : freezeLeftRegion ,
2600
2633
freezeRegions,
2601
2634
} ,
2602
2635
} ;
@@ -2610,7 +2643,9 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
2610
2643
rowMarkerOffset ,
2611
2644
showTrailingBlankRow ,
2612
2645
rows ,
2613
- freezeColumns ,
2646
+ freezeLeftColumns ,
2647
+ freezeRightColumns ,
2648
+ columns . length ,
2614
2649
freezeTrailingRows ,
2615
2650
setVisibleRegion ,
2616
2651
onVisibleRegionChanged ,
@@ -3944,7 +3979,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
3944
3979
) ;
3945
3980
} , [ onGroupHeaderRenamed , renameGroup ] ) ;
3946
3981
3947
- const mangledFreezeColumns = Math . min ( mangledCols . length , freezeColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
3982
+ const mangledFreezeColumns = Math . min ( mangledCols . length , freezeLeftColumns + ( hasRowMarkers ? 1 : 0 ) ) ;
3948
3983
3949
3984
React . useImperativeHandle (
3950
3985
forwardedRef ,
@@ -4212,7 +4247,7 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
4212
4247
onColumnProposeMove = { onColumnProposeMoveImpl }
4213
4248
drawCell = { drawCell }
4214
4249
disabledRows = { disabledRows }
4215
- freezeColumns = { mangledFreezeColumns }
4250
+ freezeColumns = { [ mangledFreezeColumns , freezeRightColumns ] }
4216
4251
lockColumns = { rowMarkerOffset }
4217
4252
firstColAccessible = { rowMarkerOffset === 0 }
4218
4253
getCellContent = { getMangledCellContent }
0 commit comments