@@ -68,6 +68,8 @@ import { findAllChildrenKeys, renderExpandIcon } from './utils/expandUtil';
68
68
// Used for conditions cache
69
69
const EMPTY_DATA = [ ] ;
70
70
71
+ export const INTERNAL_HOOKS = 'rc-table-internal-hook' ;
72
+
71
73
export interface TableProps < RecordType extends DefaultRecordType >
72
74
extends LegacyExpandableProps < RecordType > {
73
75
prefixCls ?: string ;
@@ -101,14 +103,30 @@ export interface TableProps<RecordType extends DefaultRecordType>
101
103
onHeaderRow ?: GetComponentProps < ColumnType < RecordType > [ ] > ;
102
104
emptyText ?: React . ReactNode | ( ( ) => React . ReactNode ) ;
103
105
104
- // Internal
106
+ // =================================== Internal ===================================
107
+ /**
108
+ * @private Internal usage, may remove by refactor. Should always use `columns` instead.
109
+ *
110
+ * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
111
+ */
112
+ internalHooks ?: string ;
113
+
105
114
/**
106
115
* @private Internal usage, may remove by refactor. Should always use `columns` instead.
107
116
*
108
117
* !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
109
118
*/
110
119
// Used for antd table transform column with additional column
111
120
transformColumns ?: ( columns : ColumnsType < RecordType > ) => ColumnsType < RecordType > ;
121
+
122
+ /**
123
+ * @private Internal usage, may remove by refactor.
124
+ *
125
+ * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
126
+ */
127
+ internalRefs ?: {
128
+ body : React . MutableRefObject < HTMLDivElement > ;
129
+ } ;
112
130
}
113
131
114
132
function Table < RecordType extends DefaultRecordType > ( props : TableProps < RecordType > ) {
@@ -136,7 +154,9 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
136
154
onHeaderRow,
137
155
138
156
// Internal
157
+ internalHooks,
139
158
transformColumns,
159
+ internalRefs,
140
160
} = props ;
141
161
142
162
const mergedData = data || EMPTY_DATA ;
@@ -279,7 +299,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
279
299
expandIcon : mergedExpandIcon ,
280
300
expandIconColumnIndex,
281
301
} ,
282
- transformColumns ,
302
+ internalHooks === INTERNAL_HOOKS ? transformColumns : null ,
283
303
) ;
284
304
285
305
const columnContext = {
@@ -360,6 +380,13 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
360
380
}
361
381
} , [ fixColumn ] ) ;
362
382
383
+ // ================== INTERNAL HOOKS ==================
384
+ React . useEffect ( ( ) => {
385
+ if ( internalHooks === INTERNAL_HOOKS && internalRefs ) {
386
+ internalRefs . body . current = scrollBodyRef . current ;
387
+ }
388
+ } ) ;
389
+
363
390
// ====================== Render ======================
364
391
const TableComponent = getComponent ( [ 'table' ] , 'table' ) ;
365
392
@@ -421,6 +448,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
421
448
if ( fixHeader ) {
422
449
groupTableNode = (
423
450
< >
451
+ { /* Header Table */ }
424
452
{ showHeader !== false && (
425
453
< div
426
454
style = { {
@@ -434,6 +462,8 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
434
462
< FixedHeader { ...headerProps } { ...columnContext } />
435
463
</ div >
436
464
) }
465
+
466
+ { /* Body Table */ }
437
467
< div
438
468
style = { {
439
469
...scrollXStyle ,
0 commit comments