@@ -7,13 +7,15 @@ import React, {
77 useRef ,
88 useState ,
99} from 'react' ;
10+
1011import classNames from 'classnames' ;
1112import { pick } from 'lodash-es' ;
1213
1314import log from '@tdesign/common-js/log/index' ;
1415import { getIEVersion } from '@tdesign/common-js/utils/helper' ;
1516import Affix , { type AffixRef } from '../affix' ;
1617import useDefaultProps from '../hooks/useDefaultProps' ;
18+ import useDomRefMount from '../hooks/useDomRefMount' ;
1719import useElementLazyRender from '../hooks/useElementLazyRender' ;
1820import useVirtualScroll from '../hooks/useVirtualScroll' ;
1921import Loading from '../loading' ;
@@ -125,6 +127,8 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
125127 footerBottomAffixRef,
126128 } ) ;
127129
130+ const { onMount : onAffixHeaderMount } = useDomRefMount ( affixHeaderRef ) ;
131+
128132 const { dataSource, innerPagination, isPaginateData, renderPagination } = usePagination ( props , tableContentRef ) ;
129133
130134 // 列宽拖拽逻辑
@@ -269,7 +273,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
269273 const scrollColumnIntoView = ( colKey : string ) => {
270274 if ( ! tableContentRef . current ) return ;
271275 const thDom = tableContentRef . current . querySelector ( `th[data-colkey="${ colKey } "]` ) ;
272- const fixedThDom = tableContentRef . current . querySelectorAll ( ' th.t -table__cell--fixed-left' ) ;
276+ const fixedThDom = tableContentRef . current . querySelectorAll ( ` th.${ classPrefix } -table__cell--fixed-left` ) ;
273277 let totalWidth = 0 ;
274278 for ( let i = 0 , len = fixedThDom . length ; i < len ; i ++ ) {
275279 totalWidth += fixedThDom [ i ] . getBoundingClientRect ( ) . width ;
@@ -286,6 +290,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
286290 tableHtmlElement : tableElmRef . current ,
287291 tableContentElement : tableContentRef . current ,
288292 affixHeaderElement : affixHeaderRef . current ,
293+ onAffixHeaderMount,
289294 refreshTable,
290295 scrollToElement : virtualConfig . scrollToElement ,
291296 scrollColumnIntoView,
@@ -380,7 +385,7 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
380385 } ;
381386 const affixedHeader = Boolean ( ( headerAffixedTop || virtualConfig . isVirtualScroll ) && tableWidth ) && (
382387 < div
383- ref = { affixHeaderRef }
388+ ref = { onAffixHeaderMount }
384389 style = { { width : `${ tableWidth } px` , opacity : headerOpacity } }
385390 className = { classNames ( [
386391 'scrollbar' ,
@@ -495,7 +500,6 @@ const BaseTable = forwardRef<BaseTableRef, BaseTableProps>((originalProps, ref)
495500 tableContentRef,
496501 tableWidth,
497502 isWidthOverflow,
498- allTableClasses,
499503 rowKey,
500504 scroll : props . scroll ,
501505 cellEmptyContent : props . cellEmptyContent ,
0 commit comments