@@ -86,6 +86,23 @@ export type CellProps<RecordType extends DefaultRecordType> = Omit<
86
86
keyof HoverContextProps
87
87
> ;
88
88
89
+ const getTitleFromCellRenderChildren = ( {
90
+ ellipsis,
91
+ rowType,
92
+ children,
93
+ } : Pick < InternalCellProps < any > , 'ellipsis' | 'rowType' | 'children' > ) => {
94
+ let title : string ;
95
+ const ellipsisConfig : CellEllipsisType = ellipsis === true ? { showTitle : true } : ellipsis ;
96
+ if ( ellipsisConfig && ( ellipsisConfig . showTitle || rowType === 'header' ) ) {
97
+ if ( typeof children === 'string' || typeof children === 'number' ) {
98
+ title = children . toString ( ) ;
99
+ } else if ( React . isValidElement ( children ) && typeof children . props . children === 'string' ) {
100
+ title = children . props . children ;
101
+ }
102
+ }
103
+ return title ;
104
+ } ;
105
+
89
106
function Cell < RecordType extends DefaultRecordType > (
90
107
{
91
108
prefixCls,
@@ -132,7 +149,10 @@ function Cell<RecordType extends DefaultRecordType>(
132
149
return [ children ] ;
133
150
}
134
151
135
- const value = getPathValue < object | React . ReactNode , RecordType > ( record , dataIndex ) ;
152
+ const value = getPathValue < Record < string , unknown > | React . ReactNode , RecordType > (
153
+ record ,
154
+ dataIndex ,
155
+ ) ;
136
156
137
157
// Customize render node
138
158
let returnChildNode = value ;
@@ -238,18 +258,11 @@ function Cell<RecordType extends DefaultRecordType>(
238
258
} ;
239
259
240
260
// ====================== Render ======================
241
- let title : string ;
242
- const ellipsisConfig : CellEllipsisType = ellipsis === true ? { showTitle : true } : ellipsis ;
243
- if ( ellipsisConfig && ( ellipsisConfig . showTitle || rowType === 'header' ) ) {
244
- if ( typeof mergedChildNode === 'string' || typeof mergedChildNode === 'number' ) {
245
- title = mergedChildNode . toString ( ) ;
246
- } else if (
247
- React . isValidElement ( mergedChildNode ) &&
248
- typeof mergedChildNode . props . children === 'string'
249
- ) {
250
- title = mergedChildNode . props . children ;
251
- }
252
- }
261
+ const title = getTitleFromCellRenderChildren ( {
262
+ rowType,
263
+ ellipsis,
264
+ children : childNode ,
265
+ } ) ;
253
266
254
267
const componentProps : React . TdHTMLAttributes < HTMLTableCellElement > & {
255
268
ref : React . Ref < any > ;
0 commit comments