File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
packages/module/src/DataViewTableTree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -108,14 +108,18 @@ export const DataViewTableTree: FC<DataViewTableTreeProps> = ({
108108 } ;
109109
110110 // Effect to handle expandAll behavior
111+ // Memoize the expandable IDs to avoid recalculating when rows object reference changes but structure is the same
112+ const expandableIds = useMemo ( ( ) => getExpandableNodeIds ( rows ) , [ rows ] ) ;
113+
114+ // Effect to handle expandAll behavior - only runs when IDs actually change
111115 useEffect ( ( ) => {
112116 if ( expandAll ) {
113- const expandableIds = getExpandableNodeIds ( rows ) ;
114117 setExpandedNodeIds ( expandableIds ) ;
115118 } else {
116119 setExpandedNodeIds ( [ ] ) ;
117120 }
118- } , [ expandAll , rows ] ) ;
121+ // eslint-disable-next-line react-hooks/exhaustive-deps
122+ } , [ expandAll , expandableIds . join ( ',' ) ] ) ;
119123
120124 const activeHeadState = useMemo ( ( ) => activeState ? headStates ?. [ activeState ] : undefined , [ activeState , headStates ] ) ;
121125 const activeBodyState = useMemo ( ( ) => activeState ? bodyStates ?. [ activeState ] : undefined , [ activeState , bodyStates ] ) ;
You can’t perform that action at this time.
0 commit comments