@@ -8,6 +8,8 @@ import type { ColumnType, CustomizeComponent } from '../interface';
88import ExpandedRow from './ExpandedRow' ;
99import { computedExpandedClassName } from '../utils/expandUtil' ;
1010import type { TableProps } from '..' ;
11+ import useStickyOffsets from '../hooks/useStickyOffsets' ;
12+ import { getCellFixedInfo } from '../utils/fixUtil' ;
1113
1214export interface BodyRowProps < RecordType > {
1315 record : RecordType ;
@@ -43,12 +45,14 @@ export function getCellProps<RecordType>(
4345 index : number ,
4446 rowKeys : React . Key [ ] = [ ] ,
4547 expandedRowOffset = 0 ,
48+ rowStickyOffsets ?: ReturnType < typeof useStickyOffsets > ,
4649) {
4750 const {
4851 record,
4952 prefixCls,
5053 columnsKey,
5154 fixedInfoList,
55+ flattenColumns,
5256 expandIconColumnIndex,
5357 nestExpandable,
5458 indentSize,
@@ -61,9 +65,11 @@ export function getCellProps<RecordType>(
6165 } = rowInfo ;
6266
6367 const key = columnsKey [ colIndex ] ;
64- const fixedInfo = fixedInfoList [ colIndex ] ;
68+ let fixedInfo = fixedInfoList [ colIndex ] ;
6569
66- // ============= Used for nest expandable =============
70+ if ( column . fixed && rowStickyOffsets ) {
71+ fixedInfo = getCellFixedInfo ( colIndex , colIndex , flattenColumns , rowStickyOffsets ) ;
72+ }
6773 let appendCellNode : React . ReactNode ;
6874 if ( colIndex === ( expandIconColumnIndex || 0 ) && nestExpandable ) {
6975 appendCellNode = (
@@ -143,6 +149,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
143149 const {
144150 prefixCls,
145151 flattenColumns,
152+ colWidths,
146153 expandedRowClassName,
147154 expandedRowRender,
148155 rowProps,
@@ -152,6 +159,19 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
152159 rowSupportExpand,
153160 } = rowInfo ;
154161
162+ const hasColSpanZero = React . useMemo ( ( ) => {
163+ return flattenColumns . some ( col => {
164+ const cellProps = col . onCell ?.( record , index ) || { } ;
165+ return ( cellProps . colSpan ?? 1 ) === 0 ;
166+ } ) ;
167+ } , [ flattenColumns , record , index ] ) ;
168+
169+ const rowStickyOffsets = useStickyOffsets (
170+ colWidths ,
171+ flattenColumns ,
172+ hasColSpanZero ? { record, rowIndex : index } : undefined ,
173+ ) ;
174+
155175 // Force render expand row if expanded before
156176 const expandedRef = React . useRef ( false ) ;
157177 expandedRef . current ||= expanded ;
@@ -196,6 +216,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
196216 index ,
197217 rowKeys ,
198218 expandedRowInfo ?. offset ,
219+ rowStickyOffsets ,
199220 ) ;
200221
201222 return (
0 commit comments