Skip to content

fix(AnalyticalTable): prevent unecessary horizontal scrollbar #5352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/main/src/components/AnalyticalTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,17 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp

const updateTableClientWidth = useCallback(() => {
if (tableRef.current) {
dispatch({ type: 'TABLE_RESIZE', payload: { tableClientWidth: tableRef.current.clientWidth } });
dispatch({
type: 'TABLE_RESIZE',
payload: {
tableClientWidth:
!scaleXFactor || scaleXFactor === 1
? tableRef.current.getBoundingClientRect().width
: tableRef.current.clientWidth
}
});
}
}, [tableRef.current]);
}, [tableRef.current, scaleXFactor]);

const updateRowsCount = useCallback(() => {
if (visibleRowCountMode === AnalyticalTableVisibleRowCountMode.Auto && analyticalTableRef.current?.parentElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const stateReducer = (state, action, _prevState, instance) => {
}
return state;
case 'TABLE_RESIZE':
// tableClientWidth is misleading, as only when scaled the `clientWidth` is used. In all other cases `getBoundingClientRect` is measuring the width.
return { ...state, tableClientWidth: payload.tableClientWidth };
case 'VISIBLE_ROWS':
return { ...state, visibleRows: payload.visibleRows };
Expand Down