@@ -27,7 +27,6 @@ function useColumnWidth(colWidths: readonly number[], columCount: number) {
2727export interface FixedHeaderProps < RecordType > extends HeaderProps < RecordType > {
2828 className : string ;
2929 style ?: React . CSSProperties ;
30- noData : boolean ;
3130 maxContentScroll : boolean ;
3231 colWidths : readonly number [ ] ;
3332 columCount : number ;
@@ -40,7 +39,6 @@ export interface FixedHeaderProps<RecordType> extends HeaderProps<RecordType> {
4039 tableLayout ?: TableLayout ;
4140 onScroll : ( info : { currentTarget : HTMLDivElement ; scrollLeft ?: number } ) => void ;
4241 children : ( info : HeaderProps < RecordType > ) => React . ReactNode ;
43- colGroup ?: React . ReactNode ;
4442}
4543
4644const FixedHolder = React . forwardRef < HTMLDivElement , FixedHeaderProps < any > > ( ( props , ref ) => {
@@ -51,11 +49,9 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
5149 const {
5250 className,
5351 style,
54- noData,
5552 columns,
5653 flattenColumns,
5754 colWidths,
58- colGroup,
5955 columCount,
6056 stickyOffsets,
6157 direction,
@@ -158,14 +154,16 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
158154 } , [ combinationScrollBarSize , stickyOffsets , isSticky ] ) ;
159155
160156 const mergedColumnWidth = useColumnWidth ( colWidths , columCount ) ;
161-
162- const isColGroupEmpty = useMemo < boolean > ( ( ) => {
163- // use original ColGroup if no data or no calculated column width, otherwise use calculated column width
164- // Return original colGroup if no data, or mergedColumnWidth is empty, or all widths are falsy
165- const noWidth =
166- ! mergedColumnWidth || ! mergedColumnWidth . length || mergedColumnWidth . every ( w => ! w ) ;
167- return noData || noWidth ;
168- } , [ noData , mergedColumnWidth ] ) ;
157+ const hasMergedColumnWidth = ! ! mergedColumnWidth && mergedColumnWidth . some ( width => width ) ;
158+
159+ // Use the declared column width when the measured one is unavailable
160+ // (e.g. there is no data to measure). Both cases always reserve the width
161+ // of the trailing scrollbar column, so the extra header cell keeps a stable
162+ // size and the table does not jump when data arrives.
163+ const fallbackColWidths = React . useMemo (
164+ ( ) => flattenColumns . map ( ( { width } ) => width ) ,
165+ [ flattenColumns ] ,
166+ ) ;
169167
170168 return (
171169 < div
@@ -187,15 +185,14 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
187185 width : scrollX ,
188186 } }
189187 >
190- { isColGroupEmpty ? (
191- colGroup
192- ) : (
193- < ColGroup
194- colWidths = { [ ...mergedColumnWidth , combinationScrollBarSize ] }
195- columCount = { columCount + 1 }
196- columns = { flattenColumnsWithScrollbar }
197- />
198- ) }
188+ < ColGroup
189+ colWidths = { [
190+ ...( hasMergedColumnWidth ? mergedColumnWidth : fallbackColWidths ) ,
191+ combinationScrollBarSize ,
192+ ] }
193+ columCount = { columCount + 1 }
194+ columns = { flattenColumnsWithScrollbar }
195+ />
199196 { children ( {
200197 ...restProps ,
201198 stickyOffsets : headerStickyOffsets ,
0 commit comments