@@ -118,6 +118,8 @@ export interface TableProps<RecordType = unknown>
118118
119119 direction ?: Direction ;
120120
121+ sticky ?: boolean | TableSticky ;
122+
121123 // =================================== Internal ===================================
122124 /**
123125 * @private Internal usage, may remove by refactor. Should always use `columns` instead.
@@ -143,6 +145,14 @@ export interface TableProps<RecordType = unknown>
143145 // Force column to be average width if not set
144146 tailor ?: boolean ;
145147
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+
146156 /**
147157 * @private Internal usage, may remove by refactor.
148158 *
@@ -151,8 +161,6 @@ export interface TableProps<RecordType = unknown>
151161 internalRefs ?: {
152162 body : React . MutableRefObject < HTMLDivElement > ;
153163 } ;
154-
155- sticky ?: boolean | TableSticky ;
156164}
157165
158166function defaultEmpty ( ) {
@@ -197,6 +205,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
197205 transformColumns,
198206 internalRefs,
199207 tailor,
208+ getContainerWidth,
200209
201210 sticky,
202211 } = props ;
@@ -281,6 +290,7 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
281290 expandIconColumnIndex : expandableConfig . expandIconColumnIndex ,
282291 direction,
283292 scrollWidth : useInternalHooks && tailor && typeof scrollX === 'number' ? scrollX : null ,
293+ clientWidth : componentWidth ,
284294 } ,
285295 useInternalHooks ? transformColumns : null ,
286296 ) ;
@@ -432,9 +442,14 @@ function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<Reco
432442 } ;
433443
434444 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 ) {
436451 triggerOnScroll ( ) ;
437- setComponentWidth ( fullTableRef . current ? fullTableRef . current . offsetWidth : width ) ;
452+ setComponentWidth ( mergedWidth ) ;
438453 }
439454 } ;
440455
0 commit comments