@@ -47,6 +47,7 @@ export function getCellProps<RecordType>(
47
47
expandedRowOffset = 0 ,
48
48
rowStickyOffsets ?: ReturnType < typeof useStickyOffsets > ,
49
49
hasColSpanZero ?: boolean ,
50
+ cachedCellProps ?: Record < string , any > ,
50
51
) {
51
52
const {
52
53
record,
@@ -68,7 +69,7 @@ export function getCellProps<RecordType>(
68
69
const key = columnsKey [ colIndex ] ;
69
70
let fixedInfo = fixedInfoList [ colIndex ] ;
70
71
71
- if ( column . fixed && hasColSpanZero ) {
72
+ if ( column . fixed && hasColSpanZero && rowStickyOffsets ) {
72
73
fixedInfo = getCellFixedInfo ( colIndex , colIndex , flattenColumns , rowStickyOffsets ) ;
73
74
}
74
75
let appendCellNode : React . ReactNode ;
@@ -90,7 +91,7 @@ export function getCellProps<RecordType>(
90
91
) ;
91
92
}
92
93
93
- const additionalCellProps = column . onCell ?.( record , index ) || { } ;
94
+ const additionalCellProps = cachedCellProps || column . onCell ?.( record , index ) || { } ;
94
95
95
96
// Expandable row has offset
96
97
if ( expandedRowOffset ) {
@@ -160,13 +161,14 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
160
161
rowSupportExpand,
161
162
} = rowInfo ;
162
163
163
- const hasColSpanZero = React . useMemo ( ( ) => {
164
- return flattenColumns . some ( col => {
165
- const cellProps = col . onCell ?.( record , index ) || { } ;
166
- return ( cellProps . colSpan ?? 1 ) === 0 ;
167
- } ) ;
164
+ const cellPropsCache = React . useMemo ( ( ) => {
165
+ return flattenColumns . map ( col => col . onCell ?.( record , index ) || { } ) ;
168
166
} , [ flattenColumns , record , index ] ) ;
169
167
168
+ const hasColSpanZero = React . useMemo ( ( ) => {
169
+ return cellPropsCache . some ( cellProps => ( cellProps . colSpan ?? 1 ) === 0 ) ;
170
+ } , [ cellPropsCache ] ) ;
171
+
170
172
const rowStickyOffsets = useStickyOffsets (
171
173
colWidths ,
172
174
flattenColumns ,
@@ -219,6 +221,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
219
221
expandedRowInfo ?. offset ,
220
222
rowStickyOffsets ,
221
223
hasColSpanZero ,
224
+ cellPropsCache [ colIndex ] ,
222
225
) ;
223
226
224
227
return (
0 commit comments