Skip to content

Commit e026671

Browse files
aferdkarelhala
andauthored
Update packages/module/src/DataViewTableTree/DataViewTableTree.tsx
Co-authored-by: Karel Hala <[email protected]>
1 parent 9c8835c commit e026671

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/module/src/DataViewTableTree/DataViewTableTree.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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 ]);

0 commit comments

Comments
 (0)