@@ -118,6 +118,8 @@ export interface TableProps<RecordType = unknown>
118
118
119
119
direction ?: Direction ;
120
120
121
+ sticky ?: boolean | TableSticky ;
122
+
121
123
// =================================== Internal ===================================
122
124
/**
123
125
* @private Internal usage, may remove by refactor. Should always use `columns` instead.
@@ -143,6 +145,14 @@ export interface TableProps<RecordType = unknown>
143
145
// Force column to be average width if not set
144
146
tailor ?: boolean ;
145
147
148
+ /**
149
+ * @private Internal usage, may remove by refactor.
150
+ *
151
+ * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
152
+ */
153
+ // Pass the way to get real width. e.g. exclude the border width
154
+ getContainerWidth ?: ( ele : HTMLElement , width : number ) => number ;
155
+
146
156
/**
147
157
* @private Internal usage, may remove by refactor.
148
158
*
@@ -151,8 +161,6 @@ export interface TableProps<RecordType = unknown>
151
161
internalRefs ?: {
152
162
body : React . MutableRefObject < HTMLDivElement > ;
153
163
} ;
154
-
155
- sticky ?: boolean | TableSticky ;
156
164
}
157
165
158
166
function defaultEmpty ( ) {
@@ -197,6 +205,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
197
205
transformColumns,
198
206
internalRefs,
199
207
tailor,
208
+ getContainerWidth,
200
209
201
210
sticky,
202
211
} = props ;
@@ -281,6 +290,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
281
290
expandIconColumnIndex : expandableConfig . expandIconColumnIndex ,
282
291
direction,
283
292
scrollWidth : useInternalHooks && tailor && typeof scrollX === 'number' ? scrollX : null ,
293
+ clientWidth : componentWidth ,
284
294
} ,
285
295
useInternalHooks ? transformColumns : null ,
286
296
) ;
@@ -432,9 +442,14 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
432
442
} ;
433
443
434
444
const onFullTableResize = ( { width } ) => {
435
- if ( width !== componentWidth ) {
445
+ let mergedWidth = fullTableRef . current ? fullTableRef . current . offsetWidth : width ;
446
+ if ( useInternalHooks && getContainerWidth ) {
447
+ mergedWidth = getContainerWidth ( fullTableRef . current , mergedWidth ) || mergedWidth ;
448
+ }
449
+
450
+ if ( mergedWidth !== componentWidth ) {
436
451
triggerOnScroll ( ) ;
437
- setComponentWidth ( fullTableRef . current ? fullTableRef . current . offsetWidth : width ) ;
452
+ setComponentWidth ( mergedWidth ) ;
438
453
}
439
454
} ;
440
455
0 commit comments