@@ -8,6 +8,8 @@ import type { ColumnType, CustomizeComponent } from '../interface';
8
8
import ExpandedRow from './ExpandedRow' ;
9
9
import { computedExpandedClassName } from '../utils/expandUtil' ;
10
10
import type { TableProps } from '..' ;
11
+ import useStickyOffsets from '../hooks/useStickyOffsets' ;
12
+ import { getCellFixedInfo } from '../utils/fixUtil' ;
11
13
12
14
export interface BodyRowProps < RecordType > {
13
15
record : RecordType ;
@@ -43,12 +45,14 @@ export function getCellProps<RecordType>(
43
45
index : number ,
44
46
rowKeys : React . Key [ ] = [ ] ,
45
47
expandedRowOffset = 0 ,
48
+ rowStickyOffsets ?: ReturnType < typeof useStickyOffsets > ,
46
49
) {
47
50
const {
48
51
record,
49
52
prefixCls,
50
53
columnsKey,
51
54
fixedInfoList,
55
+ flattenColumns,
52
56
expandIconColumnIndex,
53
57
nestExpandable,
54
58
indentSize,
@@ -61,9 +65,11 @@ export function getCellProps<RecordType>(
61
65
} = rowInfo ;
62
66
63
67
const key = columnsKey [ colIndex ] ;
64
- const fixedInfo = fixedInfoList [ colIndex ] ;
68
+ let fixedInfo = fixedInfoList [ colIndex ] ;
65
69
66
- // ============= Used for nest expandable =============
70
+ if ( column . fixed && rowStickyOffsets ) {
71
+ fixedInfo = getCellFixedInfo ( colIndex , colIndex , flattenColumns , rowStickyOffsets ) ;
72
+ }
67
73
let appendCellNode : React . ReactNode ;
68
74
if ( colIndex === ( expandIconColumnIndex || 0 ) && nestExpandable ) {
69
75
appendCellNode = (
@@ -143,6 +149,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
143
149
const {
144
150
prefixCls,
145
151
flattenColumns,
152
+ colWidths,
146
153
expandedRowClassName,
147
154
expandedRowRender,
148
155
rowProps,
@@ -152,6 +159,19 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
152
159
rowSupportExpand,
153
160
} = rowInfo ;
154
161
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
+
155
175
// Force render expand row if expanded before
156
176
const expandedRef = React . useRef ( false ) ;
157
177
expandedRef . current ||= expanded ;
@@ -196,6 +216,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
196
216
index ,
197
217
rowKeys ,
198
218
expandedRowInfo ?. offset ,
219
+ rowStickyOffsets ,
199
220
) ;
200
221
201
222
return (
0 commit comments