Skip to content

Commit 5255349

Browse files
authored
fix: receive an error warning when the direction is rtl (#803)
* fix: receive an error warning when the direction is rtl * fix: add test case
1 parent 6d14122 commit 5255349

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/hooks/useColumns.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function useColumns<RecordType>(
257257
}, [mergedColumns, direction]);
258258
// Only check out of production since it's waste for each render
259259
if (process.env.NODE_ENV !== 'production') {
260-
warningFixed(flattenColumns);
260+
warningFixed(direction === 'rtl' ? flattenColumns.slice().reverse() : flattenColumns);
261261
}
262262
return [mergedColumns, flattenColumns];
263263
}

tests/FixedColumn.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ describe('Table.FixedColumn', () => {
191191
"Warning: Index 2 of `columns` missing `fixed='right'` prop.",
192192
);
193193
});
194+
195+
it('RTL', () => {
196+
mount(<Table columns={[{}, { fixed: 'right' }]} direction="rtl" />);
197+
expect(errorSpy).not.toHaveBeenCalled();
198+
});
194199
});
195200

196201
it('ellipsis will wrap additional dom', () => {
@@ -207,6 +212,7 @@ describe('Table.FixedColumn', () => {
207212
);
208213
expect(wrapper.render()).toMatchSnapshot();
209214
});
215+
210216
it('has correct scroll classNames when table direction is RTL', () => {
211217
const wrapper = mount(<Table columns={columns} data={data} direction="rtl" />);
212218

0 commit comments

Comments
 (0)