Skip to content

Commit b0a09b6

Browse files
authored
fix: table header broken when scroll do not have the data(#594) (#595)
1 parent d5c3bae commit b0a09b6

3 files changed

Lines changed: 46 additions & 1 deletion

File tree

src/Header/FixedHeader.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function useColumnWidth(colWidths: readonly number[], columCount: number) {
2525

2626
export interface FixedHeaderProps<RecordType> extends HeaderProps<RecordType> {
2727
noData: boolean;
28+
maxContentScroll: boolean;
2829
colWidths: readonly number[];
2930
columCount: number;
3031
direction: 'ltr' | 'rtl';
@@ -48,6 +49,7 @@ const FixedHeader = React.forwardRef<HTMLDivElement, FixedHeaderProps<unknown>>(
4849
offsetHeader,
4950
stickyClassName,
5051
onScroll,
52+
maxContentScroll,
5153
...props
5254
},
5355
ref,
@@ -138,7 +140,7 @@ const FixedHeader = React.forwardRef<HTMLDivElement, FixedHeaderProps<unknown>>(
138140
visibility: noData || mergedColumnWidth ? null : 'hidden',
139141
}}
140142
>
141-
{(!noData || allFlattenColumnsWithWidth) && (
143+
{(!noData || !maxContentScroll || allFlattenColumnsWithWidth) && (
142144
<ColGroup
143145
colWidths={mergedColumnWidth ? [...mergedColumnWidth, combinationScrollBarSize] : []}
144146
columCount={columCount + 1}

src/Table.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
530530
stickyOffsets,
531531
onHeaderRow,
532532
fixHeader,
533+
scroll
533534
};
534535

535536
// Empty
@@ -627,6 +628,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
627628
{showHeader !== false && (
628629
<FixedHeader
629630
noData={!mergedData.length}
631+
maxContentScroll={horizonScroll && scroll.x === 'max-content'}
630632
{...headerProps}
631633
{...columnContext}
632634
direction={direction}

tests/__snapshots__/FixedColumn.spec.js.snap

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2406,6 +2406,47 @@ exports[`Table.FixedColumn renders correctly scrollXY - without data 1`] = `
24062406
<table
24072407
style="table-layout: fixed;"
24082408
>
2409+
<colgroup>
2410+
<col
2411+
style="width: 93px; min-width: 93px;"
2412+
/>
2413+
<col
2414+
style="width: 0px; min-width: 0;"
2415+
/>
2416+
<col
2417+
style="width: 0px; min-width: 0;"
2418+
/>
2419+
<col
2420+
style="width: 0px; min-width: 0;"
2421+
/>
2422+
<col
2423+
style="width: 0px; min-width: 0;"
2424+
/>
2425+
<col
2426+
style="width: 0px; min-width: 0;"
2427+
/>
2428+
<col
2429+
style="width: 0px; min-width: 0;"
2430+
/>
2431+
<col
2432+
style="width: 0px; min-width: 0;"
2433+
/>
2434+
<col
2435+
style="width: 0px; min-width: 0;"
2436+
/>
2437+
<col
2438+
style="width: 0px; min-width: 0;"
2439+
/>
2440+
<col
2441+
style="width: 0px; min-width: 0;"
2442+
/>
2443+
<col
2444+
style="width: 0px; min-width: 0;"
2445+
/>
2446+
<col
2447+
style="width: 15px; min-width: 15px;"
2448+
/>
2449+
</colgroup>
24092450
<thead
24102451
class="rc-table-thead"
24112452
>

0 commit comments

Comments
 (0)