Skip to content

Commit d22b38c

Browse files
authored
Revert "refactor: remove maxContentScroll prop and related logic from FixedHo…" (#1320)
1 parent ce95747 commit d22b38c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/FixedHolder/index.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function useColumnWidth(colWidths: readonly number[], columCount: number) {
2727
export interface FixedHeaderProps<RecordType> extends HeaderProps<RecordType> {
2828
className: string;
2929
noData: boolean;
30+
maxContentScroll: boolean;
3031
colWidths: readonly number[];
3132
columCount: number;
3233
direction: Direction;
@@ -57,6 +58,7 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
5758
stickyBottomOffset,
5859
stickyClassName,
5960
onScroll,
61+
maxContentScroll,
6062
children,
6163
...restProps
6264
} = props;
@@ -96,6 +98,12 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
9698
};
9799
}, []);
98100

101+
// Check if all flattenColumns has width
102+
const allFlattenColumnsWithWidth = React.useMemo(
103+
() => flattenColumns.every(column => column.width),
104+
[flattenColumns],
105+
);
106+
99107
// Add scrollbar column
100108
const lastColumn = flattenColumns[flattenColumns.length - 1];
101109
const ScrollBarColumn: ColumnType<unknown> & { scrollbar: true } = {
@@ -148,11 +156,13 @@ const FixedHolder = React.forwardRef<HTMLDivElement, FixedHeaderProps<any>>((pro
148156
visibility: noData || mergedColumnWidth ? null : 'hidden',
149157
}}
150158
>
151-
<ColGroup
152-
colWidths={mergedColumnWidth ? [...mergedColumnWidth, combinationScrollBarSize] : []}
153-
columCount={columCount + 1}
154-
columns={flattenColumnsWithScrollbar}
155-
/>
159+
{(!noData || !maxContentScroll || allFlattenColumnsWithWidth) && (
160+
<ColGroup
161+
colWidths={mergedColumnWidth ? [...mergedColumnWidth, combinationScrollBarSize] : []}
162+
columCount={columCount + 1}
163+
columns={flattenColumnsWithScrollbar}
164+
/>
165+
)}
156166
{children({
157167
...restProps,
158168
stickyOffsets: headerStickyOffsets,

src/Table.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,7 @@ function Table<RecordType extends DefaultRecordType>(
680680
// Fixed holder share the props
681681
const fixedHolderProps = {
682682
noData: !mergedData.length,
683+
maxContentScroll: horizonScroll && mergedScrollX === 'max-content',
683684
...headerProps,
684685
...columnContext,
685686
direction,

0 commit comments

Comments
 (0)