@@ -163,7 +163,7 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
163
163
} = props ;
164
164
165
165
useStylesheet ( styleData , AnalyticalTable . displayName ) ;
166
- const isInitial = useRef ( false ) ;
166
+ const isInitialized = useRef ( false ) ;
167
167
168
168
const alwaysShowSubComponent =
169
169
subComponentsBehavior === AnalyticalTableSubComponentsBehavior . Visible ||
@@ -309,12 +309,22 @@ const AnalyticalTable = forwardRef<AnalyticalTableDomRef, AnalyticalTablePropTyp
309
309
} ) ;
310
310
// force re-measure if `visibleColumns` change
311
311
useEffect ( ( ) => {
312
- if ( isInitial . current && visibleColumns . length ) {
312
+ if ( isInitialized . current && visibleColumns . length ) {
313
313
columnVirtualizer . measure ( ) ;
314
314
} else {
315
- isInitial . current = true ;
315
+ isInitialized . current = true ;
316
316
}
317
317
} , [ 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 ] ) ;
318
328
319
329
const [ analyticalTableRef , scrollToRef ] = useTableScrollHandles ( updatedRef , dispatch ) ;
320
330
0 commit comments