@@ -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