Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion examples/expandedRowRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const Demo = () => {
const [expandedRowKeys, setExpandedRowKeys] = React.useState([]);
const [expandRowByClick, expandRowByClickProps] = useCheckbox(false);
const [fixColumns, fixColumnsProps] = useCheckbox(false);
const [scrollX, scrollXProps] = useCheckbox(false);
const [fixHeader, fixHeaderProps] = useCheckbox(false);
const [expandIconPosition, expandIconPositionProps] = useCheckbox(false);

Expand Down Expand Up @@ -103,6 +104,10 @@ const Demo = () => {
<input {...fixColumnsProps} />
Fix Columns
</label>
<label>
<input {...scrollXProps} />
ScrollX
</label>
<label>
<input {...fixHeaderProps} />
Fix Header
Expand All @@ -123,7 +128,7 @@ const Demo = () => {
rowExpandable,
expandIconColumnIndex: expandIconPosition ? 1 : null,
}}
scroll={{ x: fixColumns ? 2000 : null, y: fixHeader ? 300 : null }}
scroll={{ x: fixColumns || scrollX ? 2000 : null, y: fixHeader ? 300 : null }}
data={data}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/Body/BodyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
const { prefixCls, direction } = React.useContext(TableContext);
const {
fixHeader,
fixColumn,
horizonScroll,
componentWidth,
flattenColumns,
expandableType,
Expand Down Expand Up @@ -196,7 +196,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
)}
prefixCls={prefixCls}
fixHeader={fixHeader}
fixColumn={fixColumn}
horizonScroll={horizonScroll}
component={RowComponent}
componentWidth={componentWidth}
cellComponent={cellComponent}
Expand Down
8 changes: 4 additions & 4 deletions src/Body/ExpandedRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ExpandedRowProps<RecordType> {
component: CustomizeComponent;
cellComponent: CustomizeComponent;
fixHeader: boolean;
fixColumn: boolean;
horizonScroll: boolean;
componentWidth: number;
className: string;
expanded: boolean;
Expand All @@ -22,7 +22,7 @@ function ExpandedRow<RecordType>({
component: Component,
cellComponent,
fixHeader,
fixColumn,
horizonScroll,
className,
expanded,
componentWidth,
Expand All @@ -34,7 +34,7 @@ function ExpandedRow<RecordType>({
return React.useMemo(() => {
let contentNode = children;

if (fixColumn) {
if (horizonScroll) {
contentNode = (
<div
style={{
Expand Down Expand Up @@ -66,7 +66,7 @@ function ExpandedRow<RecordType>({
children,
Component,
fixHeader,
fixColumn,
horizonScroll,
className,
expanded,
componentWidth,
Expand Down
6 changes: 4 additions & 2 deletions src/Body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function Body<RecordType>({
}: BodyProps<RecordType>) {
const { onColumnResize } = React.useContext(ResizeContext);
const { prefixCls, getComponent } = React.useContext(TableContext);
const { fixHeader, fixColumn, flattenColumns, componentWidth } = React.useContext(BodyContext);
const { fixHeader, horizonScroll, flattenColumns, componentWidth } = React.useContext(
BodyContext,
);

return React.useMemo(() => {
const WrapperComponent = getComponent(['body', 'wrapper'], 'tbody');
Expand Down Expand Up @@ -70,7 +72,7 @@ function Body<RecordType>({
className={`${prefixCls}-placeholder`}
prefixCls={prefixCls}
fixHeader={fixHeader}
fixColumn={fixColumn}
horizonScroll={horizonScroll}
component={trComponent}
componentWidth={componentWidth}
cellComponent={tdComponent}
Expand Down
20 changes: 10 additions & 10 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
const colWidths = React.useMemo(() => pureColWidths, [pureColWidths.join('_')]);
const stickyOffsets = useStickyOffsets(colWidths, flattenColumns.length, direction);
const fixHeader = hasData && scroll && validateValue(scroll.y);
const fixColumn = scroll && validateValue(scroll.x);
const horizonScroll = scroll && validateValue(scroll.x);

let scrollXStyle: React.CSSProperties;
let scrollYStyle: React.CSSProperties;
Expand All @@ -382,7 +382,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
};
}

if (fixColumn) {
if (horizonScroll) {
scrollXStyle = { overflowX: 'scroll' };
// When no vertical scrollbar, should hide it
// https://github.com/ant-design/ant-design/pull/20705
Expand Down Expand Up @@ -446,13 +446,13 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
setComponentWidth(fullTableRef.current ? fullTableRef.current.offsetWidth : width);
};

// Sync scroll bar when init or `fixColumn` changed
// Sync scroll bar when init or `horizonScroll` changed
React.useEffect(() => triggerOnScroll, []);
React.useEffect(() => {
if (fixColumn) {
if (horizonScroll) {
triggerOnScroll();
}
}, [fixColumn]);
}, [horizonScroll]);

// ================== INTERNAL HOOKS ==================
React.useEffect(() => {
Expand Down Expand Up @@ -501,7 +501,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
const bodyTable = (
<Body
data={mergedData}
measureColumnWidth={fixHeader || fixColumn}
measureColumnWidth={fixHeader || horizonScroll}
stickyOffsets={stickyOffsets}
expandedKeys={mergedExpandedKeys}
rowExpandable={rowExpandable}
Expand Down Expand Up @@ -625,7 +625,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
[`${prefixCls}-ping-right`]: pingedRight,
[`${prefixCls}-layout-fixed`]: tableLayout === 'fixed',
[`${prefixCls}-fixed-header`]: fixHeader,
[`${prefixCls}-fixed-column`]: fixColumn,
[`${prefixCls}-fixed-column`]: horizonScroll,
[`${prefixCls}-has-fix-left`]: flattenColumns[0] && flattenColumns[0].fixed,
[`${prefixCls}-has-fix-right`]:
flattenColumns[flattenColumns.length - 1] &&
Expand All @@ -648,7 +648,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
</div>
);

if (fixColumn) {
if (horizonScroll) {
fullTable = <ResizeObserver onResize={onFullTableResize}>{fullTable}</ResizeObserver>;
}

Expand All @@ -670,7 +670,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
expandedRowClassName,
componentWidth,
fixHeader,
fixColumn,
horizonScroll,
expandIcon: mergedExpandIcon,
expandableType,
expandRowByClick,
Expand All @@ -686,7 +686,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
expandedRowClassName,
componentWidth,
fixHeader,
fixColumn,
horizonScroll,
mergedExpandIcon,
expandableType,
expandRowByClick,
Expand Down
2 changes: 1 addition & 1 deletion src/context/BodyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface BodyContextProps<RecordType = DefaultRecordType> {
componentWidth: number;
tableLayout: TableLayout;
fixHeader: boolean;
fixColumn: boolean;
horizonScroll: boolean;

indentSize: number;
expandableType: ExpandableType;
Expand Down