From f59918ad3eda7768a8bdbd52084d60af02e6f76e Mon Sep 17 00:00:00 2001 From: weiwang Date: Thu, 14 Jul 2022 16:29:59 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=BC=80=E5=90=AFscrollX=E6=97=B6=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E5=88=97=E5=B7=A6=E5=9B=BA=E5=AE=9A=E6=97=B6=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E6=A8=AA=E5=90=91=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/index.less | 3 +- docs/demo/scrollXOnlyOne.md | 3 ++ docs/examples/scrollXOnlyOne.tsx | 51 ++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 docs/demo/scrollXOnlyOne.md create mode 100644 docs/examples/scrollXOnlyOne.tsx diff --git a/assets/index.less b/assets/index.less index d2f2d8fee..b7a3ec6fe 100644 --- a/assets/index.less +++ b/assets/index.less @@ -79,8 +79,7 @@ } } - &-fix-left-first::after, - &-fix-left-last::after { + &-fix-left-first::after { position: absolute; top: 0; right: -1px; diff --git a/docs/demo/scrollXOnlyOne.md b/docs/demo/scrollXOnlyOne.md new file mode 100644 index 000000000..94f3182b5 --- /dev/null +++ b/docs/demo/scrollXOnlyOne.md @@ -0,0 +1,3 @@ +## scrollXOnlyOne + + diff --git a/docs/examples/scrollXOnlyOne.tsx b/docs/examples/scrollXOnlyOne.tsx new file mode 100644 index 000000000..b91377603 --- /dev/null +++ b/docs/examples/scrollXOnlyOne.tsx @@ -0,0 +1,51 @@ +import React from 'react'; +import Table from 'rc-table'; +import '../../assets/index.less'; + +const columns = [ + { + title: 'title0', + dataIndex: 'a', + key: 'a', + width: 100, + fixed: 'left', + }, + { + title: 'title1', + dataIndex: 'b', + key: 'b', + width: 100, + fixed: 'left', + }, + { + title: 'title2', + dataIndex: 'c', + key: 'c', + width: 100, + fixed: 'left', + }, + { + title: 'title3', + dataIndex: 'd', + key: 'd', + width: 100, + fixed: 'left', + }, +]; + +const data = [ + { a: '123', b: 'xxxxxxxx xxxxxxxx', d: 3, key: '1' }, + { a: 'cdd', b: 'edd12221 edd12221', d: 3, key: '2' }, + { a: '133', c: 'edd12221 edd12221', d: 2, key: '3' }, + { a: '133', c: 'edd12221 edd12221', d: 2, key: '4' }, +]; + +const Demo = () => ( +
+

Scroll X Only one

+ + {/*
*/} + +); + +export default Demo; From 07e8fc5e09cbb2d0861ddb702da8ff684952b7c8 Mon Sep 17 00:00:00 2001 From: weiwang Date: Thu, 14 Jul 2022 17:29:45 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=9C=A8=E6=89=80=E6=9C=89=E5=88=97=E5=85=A8=E6=98=AF=E5=B7=A6?= =?UTF-8?q?=E5=9B=BA=E5=AE=9A=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E4=BC=9A?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=A8=AA=E5=90=91=E6=BB=9A=E5=8A=A8=E6=9D=A1?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/index.less | 7 ++++- docs/demo/scrollXOnlyOne.md | 3 -- docs/examples/scrollXOnlyOne.tsx | 51 -------------------------------- src/Cell/index.tsx | 4 +++ src/Table.tsx | 1 + src/context/BodyContext.tsx | 1 + 6 files changed, 12 insertions(+), 55 deletions(-) delete mode 100644 docs/demo/scrollXOnlyOne.md delete mode 100644 docs/examples/scrollXOnlyOne.tsx diff --git a/assets/index.less b/assets/index.less index b7a3ec6fe..59332bce6 100644 --- a/assets/index.less +++ b/assets/index.less @@ -79,7 +79,8 @@ } } - &-fix-left-first::after { + &-fix-left-first::after, + &-fix-left-last::after { position: absolute; top: 0; right: -1px; @@ -91,6 +92,10 @@ pointer-events: none; } + &-all-fix-left::after { + display: none; + } + &-fix-right-first, &-fix-right-last { box-shadow: -1px 0 0 @border-color; diff --git a/docs/demo/scrollXOnlyOne.md b/docs/demo/scrollXOnlyOne.md deleted file mode 100644 index 94f3182b5..000000000 --- a/docs/demo/scrollXOnlyOne.md +++ /dev/null @@ -1,3 +0,0 @@ -## scrollXOnlyOne - - diff --git a/docs/examples/scrollXOnlyOne.tsx b/docs/examples/scrollXOnlyOne.tsx deleted file mode 100644 index b91377603..000000000 --- a/docs/examples/scrollXOnlyOne.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import React from 'react'; -import Table from 'rc-table'; -import '../../assets/index.less'; - -const columns = [ - { - title: 'title0', - dataIndex: 'a', - key: 'a', - width: 100, - fixed: 'left', - }, - { - title: 'title1', - dataIndex: 'b', - key: 'b', - width: 100, - fixed: 'left', - }, - { - title: 'title2', - dataIndex: 'c', - key: 'c', - width: 100, - fixed: 'left', - }, - { - title: 'title3', - dataIndex: 'd', - key: 'd', - width: 100, - fixed: 'left', - }, -]; - -const data = [ - { a: '123', b: 'xxxxxxxx xxxxxxxx', d: 3, key: '1' }, - { a: 'cdd', b: 'edd12221 edd12221', d: 3, key: '2' }, - { a: '133', c: 'edd12221 edd12221', d: 2, key: '3' }, - { a: '133', c: 'edd12221 edd12221', d: 2, key: '4' }, -]; - -const Demo = () => ( -
-

Scroll X Only one

-
- {/*
*/} - -); - -export default Demo; diff --git a/src/Cell/index.tsx b/src/Cell/index.tsx index 5d8d2fe22..de3f6fbda 100644 --- a/src/Cell/index.tsx +++ b/src/Cell/index.tsx @@ -15,6 +15,7 @@ import type { import { getPathValue, validateValue } from '../utils/valueUtil'; import StickyContext from '../context/StickyContext'; import HoverContext from '../context/HoverContext'; +import BodyContext from '../context/BodyContext'; import type { HoverContextProps } from '../context/HoverContext'; import warning from 'rc-util/lib/warning'; import PerfContext from '../context/PerfContext'; @@ -67,6 +68,7 @@ interface InternalCellProps lastFixLeft?: boolean; firstFixRight?: boolean; lastFixRight?: boolean; + allColsFixedLeft?: boolean; // ====================== Private Props ====================== /** @private Used for `expandable` with nest tree */ @@ -141,6 +143,7 @@ function Cell( const perfRecord = React.useContext(PerfContext); const supportSticky = React.useContext(StickyContext); + const { allColumnsFixedLeft } = React.useContext(BodyContext); // ==================== Child Node ==================== const [childNode, legacyCellProps] = React.useMemo< @@ -280,6 +283,7 @@ function Cell( [`${cellPrefixCls}-fix-left`]: isFixLeft && supportSticky, [`${cellPrefixCls}-fix-left-first`]: firstFixLeft && supportSticky, [`${cellPrefixCls}-fix-left-last`]: lastFixLeft && supportSticky, + [`${cellPrefixCls}-all-fix-left`]: allColumnsFixedLeft && supportSticky, [`${cellPrefixCls}-fix-right`]: isFixRight && supportSticky, [`${cellPrefixCls}-fix-right-first`]: firstFixRight && supportSticky, [`${cellPrefixCls}-fix-right-last`]: lastFixRight && supportSticky, diff --git a/src/Table.tsx b/src/Table.tsx index 51383a158..cd31bd0d0 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -822,6 +822,7 @@ function Table(props: TableProps col.fixed === 'left'), }), [ columnContext, diff --git a/src/context/BodyContext.tsx b/src/context/BodyContext.tsx index 5f7233971..c0d2ccb85 100644 --- a/src/context/BodyContext.tsx +++ b/src/context/BodyContext.tsx @@ -27,6 +27,7 @@ export interface BodyContextProps { expandIcon: RenderExpandIcon; onTriggerExpand: TriggerEventHandler; expandIconColumnIndex: number; + allColumnsFixedLeft: boolean; } const BodyContext = React.createContext(null); From df6222cb1dcf03ea5c8ea3ea739e65f7a6157a53 Mon Sep 17 00:00:00 2001 From: weiwang Date: Thu, 14 Jul 2022 17:54:10 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Cell/index.tsx | 2 +- tests/FixedColumn.spec.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Cell/index.tsx b/src/Cell/index.tsx index de3f6fbda..541eea168 100644 --- a/src/Cell/index.tsx +++ b/src/Cell/index.tsx @@ -283,7 +283,7 @@ function Cell( [`${cellPrefixCls}-fix-left`]: isFixLeft && supportSticky, [`${cellPrefixCls}-fix-left-first`]: firstFixLeft && supportSticky, [`${cellPrefixCls}-fix-left-last`]: lastFixLeft && supportSticky, - [`${cellPrefixCls}-all-fix-left`]: allColumnsFixedLeft && supportSticky, + [`${cellPrefixCls}-all-fix-left`]: lastFixLeft && allColumnsFixedLeft && supportSticky, [`${cellPrefixCls}-fix-right`]: isFixRight && supportSticky, [`${cellPrefixCls}-fix-right-first`]: firstFixRight && supportSticky, [`${cellPrefixCls}-fix-right-last`]: lastFixRight && supportSticky, diff --git a/tests/FixedColumn.spec.js b/tests/FixedColumn.spec.js index 18fe541b5..b521546fe 100644 --- a/tests/FixedColumn.spec.js +++ b/tests/FixedColumn.spec.js @@ -272,4 +272,9 @@ describe('Table.FixedColumn', () => { wrapper.update(); expect(wrapper.find('.rc-table-measure-row td')).toHaveLength(4); }); + + it('when all columns fixed left,cell should has classname rc-table-cell-all-fix-left', () => { + const wrapper = mount(
); + expect(wrapper.find('.rc-table-cell-all-fix-left')).toHaveLength(10); + }); }); From 44fd2eb268adf89a5b1367009634a453f300f2bc Mon Sep 17 00:00:00 2001 From: dashaowang Date: Thu, 14 Jul 2022 19:51:11 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E5=B7=A6=E5=9B=BA=E5=AE=9A=E6=97=B6=E7=9A=84?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/index.less | 2 +- src/Cell/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/index.less b/assets/index.less index 59332bce6..25ce61ea5 100644 --- a/assets/index.less +++ b/assets/index.less @@ -92,7 +92,7 @@ pointer-events: none; } - &-all-fix-left::after { + &-fix-left-all::after { display: none; } diff --git a/src/Cell/index.tsx b/src/Cell/index.tsx index 541eea168..6a1aae867 100644 --- a/src/Cell/index.tsx +++ b/src/Cell/index.tsx @@ -283,7 +283,7 @@ function Cell( [`${cellPrefixCls}-fix-left`]: isFixLeft && supportSticky, [`${cellPrefixCls}-fix-left-first`]: firstFixLeft && supportSticky, [`${cellPrefixCls}-fix-left-last`]: lastFixLeft && supportSticky, - [`${cellPrefixCls}-all-fix-left`]: lastFixLeft && allColumnsFixedLeft && supportSticky, + [`${cellPrefixCls}-fix-left-all`]: lastFixLeft && allColumnsFixedLeft && supportSticky, [`${cellPrefixCls}-fix-right`]: isFixRight && supportSticky, [`${cellPrefixCls}-fix-right-first`]: firstFixRight && supportSticky, [`${cellPrefixCls}-fix-right-last`]: lastFixRight && supportSticky, From 2569a9666469ce0d370f0d2170ee6438e8ab90a3 Mon Sep 17 00:00:00 2001 From: weiwang Date: Fri, 15 Jul 2022 10:48:32 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix:=E6=9B=B4=E6=96=B0=E6=89=80=E6=9C=89?= =?UTF-8?q?=E7=9A=84=E8=A1=A8=E6=A0=BC=E5=88=97=E5=B7=A6=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E7=9A=84=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/FixedColumn.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/FixedColumn.spec.js b/tests/FixedColumn.spec.js index b521546fe..ac0b19491 100644 --- a/tests/FixedColumn.spec.js +++ b/tests/FixedColumn.spec.js @@ -273,8 +273,8 @@ describe('Table.FixedColumn', () => { expect(wrapper.find('.rc-table-measure-row td')).toHaveLength(4); }); - it('when all columns fixed left,cell should has classname rc-table-cell-all-fix-left', () => { + it('when all columns fixed left,cell should has classname rc-table-cell-fix-left-all', () => { const wrapper = mount(
); - expect(wrapper.find('.rc-table-cell-all-fix-left')).toHaveLength(10); + expect(wrapper.find('.rc-table-cell-fix-left-all')).toHaveLength(10); }); });