Skip to content

Commit 6e9f89b

Browse files
authored
fix(AnalyticalTable): fix horizontal scrolling in rtl reading direction (#5144)
Fixes #5094
1 parent b0c9013 commit 6e9f89b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/main/src/components/AnalyticalTable/AnalyticalTable.cy.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,31 @@ describe('AnalyticalTable', () => {
280280
cy.get('@scroll').should('have.been.called');
281281
});
282282

283+
it('horizontal scrolling - rtl', () => {
284+
function generateMockData() {
285+
const data = [];
286+
287+
for (let i = 1; i <= 200; i++) {
288+
const row = {};
289+
for (let j = 1; j <= 200; j++) {
290+
row[`column${j}`] = `${i}-${j}`;
291+
}
292+
data.push(row);
293+
}
294+
295+
return data;
296+
}
297+
298+
const data = generateMockData();
299+
const columns = new Array(100)
300+
.fill('')
301+
.map((_, i) => ({ accessor: `column${i + 1}`, Header: `${i + 1} Column`, width: 100 }));
302+
cy.mount(<AnalyticalTable dir="rtl" columns={columns} data={data} />);
303+
cy.get('[data-component-name="AnalyticalTableContainer"]').scrollTo(-10000, 0);
304+
cy.findByText('100 Column').should('be.visible');
305+
cy.findByText('1-100').should('be.visible');
306+
});
307+
283308
it('tree selection & filtering', () => {
284309
const TreeSelectFilterTable = (props: PropTypes) => {
285310
const [filter, setFilter] = useState('');

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
11061106
getScrollElement: () => tableRef.current,
11071107
estimateSize: useCallback((index) => visibleColumnsWidth[index], [visibleColumnsWidth]),
11081108
horizontal: true,
1109-
overscan: overscanCountHorizontal,
1109+
overscan: isRtl ? Infinity : overscanCountHorizontal,
11101110
indexAttribute: 'data-column-index',
11111111
// necessary as otherwise values are rounded which leads to wrong total width calculation
11121112
measureElement: (el) => el.getBoundingClientRect().width

0 commit comments

Comments
 (0)