From 37527eb285bdd0a4f7b6f4787cff71bd798e4008 Mon Sep 17 00:00:00 2001 From: dengqing <1247748612@qq.com> Date: Thu, 5 May 2022 19:01:59 +0800 Subject: [PATCH 1/2] fix: receive an error warning when the direction is rtl --- src/hooks/useColumns.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useColumns.tsx b/src/hooks/useColumns.tsx index e59d785e7..891a5a2fd 100644 --- a/src/hooks/useColumns.tsx +++ b/src/hooks/useColumns.tsx @@ -257,7 +257,7 @@ function useColumns( }, [mergedColumns, direction]); // Only check out of production since it's waste for each render if (process.env.NODE_ENV !== 'production') { - warningFixed(flattenColumns); + warningFixed(direction === 'rtl' ? flattenColumns.slice().reverse() : flattenColumns); } return [mergedColumns, flattenColumns]; } From 9dd54054a2e1ca60d87717cfed3ab5a72f00dee9 Mon Sep 17 00:00:00 2001 From: dengqing <1247748612@qq.com> Date: Thu, 5 May 2022 19:02:29 +0800 Subject: [PATCH 2/2] fix: add test case --- tests/FixedColumn.spec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/FixedColumn.spec.js b/tests/FixedColumn.spec.js index 11078100e..88869c546 100644 --- a/tests/FixedColumn.spec.js +++ b/tests/FixedColumn.spec.js @@ -191,6 +191,11 @@ describe('Table.FixedColumn', () => { "Warning: Index 2 of `columns` missing `fixed='right'` prop.", ); }); + + it('RTL', () => { + mount(); + expect(errorSpy).not.toHaveBeenCalled(); + }); }); it('ellipsis will wrap additional dom', () => { @@ -207,6 +212,7 @@ describe('Table.FixedColumn', () => { ); expect(wrapper.render()).toMatchSnapshot(); }); + it('has correct scroll classNames when table direction is RTL', () => { const wrapper = mount(
);