Skip to content

Commit 16e1803

Browse files
authored
fix(AnalyticalTable): apply correct column width when hiding columns (#6848)
Fixes #5938
1 parent 6d95725 commit 16e1803

File tree

1 file changed

+10
-0
lines changed
  • packages/main/src/components/AnalyticalTable

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
163163
} = props;
164164

165165
useStylesheet(styleData, AnalyticalTable.displayName);
166+
const isInitial = useRef(false);
166167

167168
const alwaysShowSubComponent =
168169
subComponentsBehavior === AnalyticalTableSubComponentsBehavior.Visible ||
@@ -301,6 +302,15 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
301302
// necessary as otherwise values are rounded which leads to wrong total width calculation leading to unnecessary scrollbar
302303
measureElement: !scaleXFactor || scaleXFactor === 1 ? (el) => el.getBoundingClientRect().width : undefined
303304
});
305+
// force re-measure if `visibleColumns` change
306+
useEffect(() => {
307+
if (isInitial.current && visibleColumns.length) {
308+
columnVirtualizer.measure();
309+
} else {
310+
isInitial.current = true;
311+
}
312+
}, [visibleColumns.length]);
313+
304314
const [analyticalTableRef, scrollToRef] = useTableScrollHandles(updatedRef, dispatch);
305315

306316
if (parentRef.current) {

0 commit comments

Comments
 (0)