Skip to content

Commit

Permalink
fix: table header broken when scroll do not have the data(#594) (#595)
Browse files Browse the repository at this point in the history
  • Loading branch information
geekrainy authored Mar 18, 2021
1 parent d5c3bae commit b0a09b6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Header/FixedHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function useColumnWidth(colWidths: readonly number[], columCount: number) {

export interface FixedHeaderProps<RecordType> extends HeaderProps<RecordType> {
noData: boolean;
maxContentScroll: boolean;
colWidths: readonly number[];
columCount: number;
direction: 'ltr' | 'rtl';
Expand All @@ -48,6 +49,7 @@ const FixedHeader = React.forwardRef<HTMLDivElement, FixedHeaderProps<unknown>>(
offsetHeader,
stickyClassName,
onScroll,
maxContentScroll,
...props
},
ref,
Expand Down Expand Up @@ -138,7 +140,7 @@ const FixedHeader = React.forwardRef<HTMLDivElement, FixedHeaderProps<unknown>>(
visibility: noData || mergedColumnWidth ? null : 'hidden',
}}
>
{(!noData || allFlattenColumnsWithWidth) && (
{(!noData || !maxContentScroll || allFlattenColumnsWithWidth) && (
<ColGroup
colWidths={mergedColumnWidth ? [...mergedColumnWidth, combinationScrollBarSize] : []}
columCount={columCount + 1}
Expand Down
2 changes: 2 additions & 0 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
stickyOffsets,
onHeaderRow,
fixHeader,
scroll
};

// Empty
Expand Down Expand Up @@ -627,6 +628,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
{showHeader !== false && (
<FixedHeader
noData={!mergedData.length}
maxContentScroll={horizonScroll && scroll.x === 'max-content'}
{...headerProps}
{...columnContext}
direction={direction}
Expand Down
41 changes: 41 additions & 0 deletions tests/__snapshots__/FixedColumn.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2406,6 +2406,47 @@ exports[`Table.FixedColumn renders correctly scrollXY - without data 1`] = `
<table
style="table-layout: fixed;"
>
<colgroup>
<col
style="width: 93px; min-width: 93px;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 0px; min-width: 0;"
/>
<col
style="width: 15px; min-width: 15px;"
/>
</colgroup>
<thead
class="rc-table-thead"
>
Expand Down

1 comment on commit b0a09b6

@vercel
Copy link

@vercel vercel bot commented on b0a09b6 Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.