Skip to content

fix(AnalyticalTable): apply correct column width when hiding columns #6848

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
Jan 27, 2025
Merged
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
10 changes: 10 additions & 0 deletions packages/main/src/components/AnalyticalTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
} = props;

useStylesheet(styleData, AnalyticalTable.displayName);
const isInitial = useRef(false);

const alwaysShowSubComponent =
subComponentsBehavior === AnalyticalTableSubComponentsBehavior.Visible ||
Expand Down Expand Up @@ -301,6 +302,15 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
// necessary as otherwise values are rounded which leads to wrong total width calculation leading to unnecessary scrollbar
measureElement: !scaleXFactor || scaleXFactor === 1 ? (el) => el.getBoundingClientRect().width : undefined
});
// force re-measure if `visibleColumns` change
useEffect(() => {
if (isInitial.current && visibleColumns.length) {
columnVirtualizer.measure();
} else {
isInitial.current = true;
}
}, [visibleColumns.length]);

const [analyticalTableRef, scrollToRef] = useTableScrollHandles(updatedRef, dispatch);

if (parentRef.current) {
Expand Down
Loading