Skip to content

Commit 05297a7

Browse files
authored
fix(AnalyticalTable): prevent unecessary horizontal scrollbar (#5352)
1 parent 481c5ce commit 05297a7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,17 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
343343

344344
const updateTableClientWidth = useCallback(() => {
345345
if (tableRef.current) {
346-
dispatch({ type: 'TABLE_RESIZE', payload: { tableClientWidth: tableRef.current.clientWidth } });
346+
dispatch({
347+
type: 'TABLE_RESIZE',
348+
payload: {
349+
tableClientWidth:
350+
!scaleXFactor || scaleXFactor === 1
351+
? tableRef.current.getBoundingClientRect().width
352+
: tableRef.current.clientWidth
353+
}
354+
});
347355
}
348-
}, [tableRef.current]);
356+
}, [tableRef.current, scaleXFactor]);
349357

350358
const updateRowsCount = useCallback(() => {
351359
if (visibleRowCountMode === AnalyticalTableVisibleRowCountMode.Auto && analyticalTableRef.current?.parentElement) {

packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const stateReducer = (state, action, _prevState, instance) => {
3838
}
3939
return state;
4040
case 'TABLE_RESIZE':
41+
// tableClientWidth is misleading, as only when scaled the `clientWidth` is used. In all other cases `getBoundingClientRect` is measuring the width.
4142
return { ...state, tableClientWidth: payload.tableClientWidth };
4243
case 'VISIBLE_ROWS':
4344
return { ...state, visibleRows: payload.visibleRows };

0 commit comments

Comments
 (0)