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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
...base,
rules: {
...base.rules,
'arrow-parens': 0,
'react/no-array-index-key': 0,
'react/sort-comp': 0,
'@typescript-eslint/no-explicit-any': 1,
Expand Down
2 changes: 2 additions & 0 deletions src/Body/BodyRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
const { prefixCls, direction } = React.useContext(TableContext);
const {
fixHeader,
fixColumn,
horizonScroll,
componentWidth,
flattenColumns,
Expand Down Expand Up @@ -196,6 +197,7 @@ function BodyRow<RecordType extends { children?: RecordType[] }>(props: BodyRowP
)}
prefixCls={prefixCls}
fixHeader={fixHeader}
fixColumn={fixColumn}
horizonScroll={horizonScroll}
component={RowComponent}
componentWidth={componentWidth}
Expand Down
4 changes: 3 additions & 1 deletion src/Body/ExpandedRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface ExpandedRowProps<RecordType> {
component: CustomizeComponent;
cellComponent: CustomizeComponent;
fixHeader: boolean;
fixColumn: boolean;
horizonScroll: boolean;
componentWidth: number;
className: string;
Expand All @@ -22,6 +23,7 @@ function ExpandedRow<RecordType>({
component: Component,
cellComponent,
fixHeader,
fixColumn,
horizonScroll,
className,
expanded,
Expand All @@ -34,7 +36,7 @@ function ExpandedRow<RecordType>({
return React.useMemo(() => {
let contentNode = children;

if (horizonScroll) {
if (fixColumn) {
contentNode = (
<div
style={{
Expand Down
1 change: 1 addition & 0 deletions src/Body/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function Body<RecordType>({
className={`${prefixCls}-placeholder`}
prefixCls={prefixCls}
fixHeader={fixHeader}
fixColumn={horizonScroll}
horizonScroll={horizonScroll}
component={trComponent}
componentWidth={componentWidth}
Expand Down
9 changes: 6 additions & 3 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
const stickyOffsets = useStickyOffsets(colWidths, flattenColumns.length, direction);
const fixHeader = hasData && scroll && validateValue(scroll.y);
const horizonScroll = scroll && validateValue(scroll.x);
const fixColumn = horizonScroll && flattenColumns.some(({ fixed }) => fixed);

let scrollXStyle: React.CSSProperties;
let scrollYStyle: React.CSSProperties;
Expand Down Expand Up @@ -469,11 +470,11 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
if (tableLayout) {
return tableLayout;
}
if (fixHeader || flattenColumns.some(({ ellipsis, fixed }) => ellipsis || fixed)) {
if (fixHeader || fixColumn || flattenColumns.some(({ ellipsis }) => ellipsis)) {
return 'fixed';
}
return 'auto';
}, [fixHeader, flattenColumns, tableLayout]);
}, [fixHeader, fixColumn, flattenColumns, tableLayout]);

let groupTableNode: React.ReactNode;

Expand Down Expand Up @@ -625,7 +626,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`]: horizonScroll,
[`${prefixCls}-fixed-column`]: fixColumn,
[`${prefixCls}-has-fix-left`]: flattenColumns[0] && flattenColumns[0].fixed,
[`${prefixCls}-has-fix-right`]:
flattenColumns[flattenColumns.length - 1] &&
Expand Down Expand Up @@ -670,6 +671,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
expandedRowClassName,
componentWidth,
fixHeader,
fixColumn,
horizonScroll,
expandIcon: mergedExpandIcon,
expandableType,
Expand All @@ -686,6 +688,7 @@ function Table<RecordType extends DefaultRecordType>(props: TableProps<RecordTyp
expandedRowClassName,
componentWidth,
fixHeader,
fixColumn,
horizonScroll,
mergedExpandIcon,
expandableType,
Expand Down
1 change: 1 addition & 0 deletions src/context/BodyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface BodyContextProps<RecordType = DefaultRecordType> {
componentWidth: number;
tableLayout: TableLayout;
fixHeader: boolean;
fixColumn: boolean;
horizonScroll: boolean;

indentSize: number;
Expand Down
4 changes: 3 additions & 1 deletion tests/FixedColumn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ describe('Table.FixedColumn', () => {
});

it('fixed column renders correctly RTL', () => {
const wrapper = mount(<Table columns={columns} data={data} direction="rtl" />);
const wrapper = mount(
<Table columns={columns} data={data} direction="rtl" scroll={{ x: 1 }} />,
);
expect(wrapper.render()).toMatchSnapshot();
});
it('has correct scroll classNames when table direction is RTL', () => {
Expand Down
47 changes: 45 additions & 2 deletions tests/__snapshots__/FixedColumn.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

exports[`Table.FixedColumn fixed column renders correctly RTL 1`] = `
<div
class="rc-table rc-table-rtl rc-table-has-fix-left"
class="rc-table rc-table-rtl rc-table-fixed-column rc-table-has-fix-left"
>
<div
class="rc-table-container"
>
<div
class="rc-table-content"
style="overflow-x: scroll; overflow-y: hidden;"
>
<table
style="table-layout: fixed;"
style="width: 1px; min-width: 100%; table-layout: fixed;"
>
<colgroup>
<col
Expand Down Expand Up @@ -105,6 +106,48 @@ exports[`Table.FixedColumn fixed column renders correctly RTL 1`] = `
<tbody
class="rc-table-tbody"
>
<tr
aria-hidden="true"
class="rc-table-measure-row"
style="height: 0px;"
>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
<td
style="padding: 0px; border: 0px; height: 0px;"
/>
</tr>
<tr
class="rc-table-row rc-table-row-level-0"
data-row-key="1"
Expand Down
2 changes: 1 addition & 1 deletion tests/__snapshots__/Table.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ exports[`Table.Basic custom components renders fixed column and header correctly

exports[`Table.Basic custom components scroll content with scroll 1`] = `
<div
class="rc-table rc-table-fixed-header rc-table-fixed-column"
class="rc-table rc-table-fixed-header"
>
<div
class="rc-table-container"
Expand Down