From 3adc8ec9dbe99dd7b929f46900a7292bd83cfee6 Mon Sep 17 00:00:00 2001 From: zombiej Date: Wed, 1 Apr 2020 17:31:58 +0800 Subject: [PATCH 1/2] not fixed expand when scroll x only --- .eslintrc.js | 1 + src/Body/BodyRow.tsx | 2 ++ src/Body/ExpandedRow.tsx | 4 +++- src/Body/index.tsx | 1 + src/Table.tsx | 7 +++++-- src/context/BodyContext.tsx | 1 + 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index e75449fee..5b4f4d681 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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, diff --git a/src/Body/BodyRow.tsx b/src/Body/BodyRow.tsx index 02028bd1b..34074c837 100644 --- a/src/Body/BodyRow.tsx +++ b/src/Body/BodyRow.tsx @@ -52,6 +52,7 @@ function BodyRow(props: BodyRowP const { prefixCls, direction } = React.useContext(TableContext); const { fixHeader, + fixColumn, horizonScroll, componentWidth, flattenColumns, @@ -196,6 +197,7 @@ function BodyRow(props: BodyRowP )} prefixCls={prefixCls} fixHeader={fixHeader} + fixColumn={fixColumn} horizonScroll={horizonScroll} component={RowComponent} componentWidth={componentWidth} diff --git a/src/Body/ExpandedRow.tsx b/src/Body/ExpandedRow.tsx index 0ca68ee2d..08c1a6fe2 100644 --- a/src/Body/ExpandedRow.tsx +++ b/src/Body/ExpandedRow.tsx @@ -8,6 +8,7 @@ export interface ExpandedRowProps { component: CustomizeComponent; cellComponent: CustomizeComponent; fixHeader: boolean; + fixColumn: boolean; horizonScroll: boolean; componentWidth: number; className: string; @@ -22,6 +23,7 @@ function ExpandedRow({ component: Component, cellComponent, fixHeader, + fixColumn, horizonScroll, className, expanded, @@ -34,7 +36,7 @@ function ExpandedRow({ return React.useMemo(() => { let contentNode = children; - if (horizonScroll) { + if (fixColumn) { contentNode = (
({ className={`${prefixCls}-placeholder`} prefixCls={prefixCls} fixHeader={fixHeader} + fixColumn={false} horizonScroll={horizonScroll} component={trComponent} componentWidth={componentWidth} diff --git a/src/Table.tsx b/src/Table.tsx index 743a0c377..193e46bfd 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -370,6 +370,7 @@ function Table(props: TableProps fixed); let scrollXStyle: React.CSSProperties; let scrollYStyle: React.CSSProperties; @@ -469,7 +470,7 @@ function Table(props: TableProps ellipsis || fixed)) { + if (fixHeader || fixColumn || flattenColumns.some(({ ellipsis }) => ellipsis)) { return 'fixed'; } return 'auto'; @@ -625,7 +626,7 @@ function Table(props: TableProps(props: TableProps(props: TableProps { componentWidth: number; tableLayout: TableLayout; fixHeader: boolean; + fixColumn: boolean; horizonScroll: boolean; indentSize: number; From 7d726fef1dd0caa05953a7da19b973155b103f12 Mon Sep 17 00:00:00 2001 From: zombiej Date: Wed, 1 Apr 2020 17:55:36 +0800 Subject: [PATCH 2/2] update test case --- src/Body/index.tsx | 2 +- src/Table.tsx | 2 +- tests/FixedColumn.spec.js | 4 +- tests/__snapshots__/FixedColumn.spec.js.snap | 47 +++++++++++++++++++- tests/__snapshots__/Table.spec.js.snap | 2 +- 5 files changed, 51 insertions(+), 6 deletions(-) diff --git a/src/Body/index.tsx b/src/Body/index.tsx index 5ecc6127d..e10170e5a 100644 --- a/src/Body/index.tsx +++ b/src/Body/index.tsx @@ -72,7 +72,7 @@ function Body({ className={`${prefixCls}-placeholder`} prefixCls={prefixCls} fixHeader={fixHeader} - fixColumn={false} + fixColumn={horizonScroll} horizonScroll={horizonScroll} component={trComponent} componentWidth={componentWidth} diff --git a/src/Table.tsx b/src/Table.tsx index 193e46bfd..df5e15a88 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -474,7 +474,7 @@ function Table(props: TableProps { }); it('fixed column renders correctly RTL', () => { - const wrapper = mount(); + const wrapper = mount( +
, + ); expect(wrapper.render()).toMatchSnapshot(); }); it('has correct scroll classNames when table direction is RTL', () => { diff --git a/tests/__snapshots__/FixedColumn.spec.js.snap b/tests/__snapshots__/FixedColumn.spec.js.snap index 3a85d77af..fd7508b2d 100644 --- a/tests/__snapshots__/FixedColumn.spec.js.snap +++ b/tests/__snapshots__/FixedColumn.spec.js.snap @@ -2,16 +2,17 @@ exports[`Table.FixedColumn fixed column renders correctly RTL 1`] = `
+ +