Skip to content

Commit b5c3c2b

Browse files
authored
fix(AnalyticalTable): update column widths correctly when grouped or reordered (#7210)
Internal Reference: MXP-2983
1 parent 3c25985 commit b5c3c2b

File tree

1 file changed

+13
-3
lines changed
  • packages/main/src/components/AnalyticalTable

1 file changed

+13
-3
lines changed

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

+13-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
163163
} = props;
164164

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

168168
const alwaysShowSubComponent =
169169
subComponentsBehavior === AnalyticalTableSubComponentsBehavior.Visible ||
@@ -309,12 +309,22 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
309309
});
310310
// force re-measure if `visibleColumns` change
311311
useEffect(() => {
312-
if (isInitial.current && visibleColumns.length) {
312+
if (isInitialized.current && visibleColumns.length) {
313313
columnVirtualizer.measure();
314314
} else {
315-
isInitial.current = true;
315+
isInitialized.current = true;
316316
}
317317
}, [visibleColumns.length]);
318+
// force re-measure if `state.groupBy` or `state.columnOrder` changes
319+
useEffect(() => {
320+
if (isInitialized.current && (tableState.groupBy || tableState.columnOrder)) {
321+
setTimeout(() => {
322+
columnVirtualizer.measure();
323+
}, 100);
324+
} else {
325+
isInitialized.current = true;
326+
}
327+
}, [tableState.groupBy, tableState.columnOrder]);
318328

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

0 commit comments

Comments
 (0)