Skip to content

Commit

Permalink
fix(tree): fix expandAll dynamic change behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
RSS1102 committed Jan 23, 2025
1 parent 57d4b92 commit 37951bf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tree/hooks/useTreeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,19 @@ export default function useTreeStore(state: TypeTreeState) {
});
});

watch(refProps.expandAll, (nVal) => {
if (nVal) {
const valueList = store
.getNodes()
.filter((node) => Array.isArray(node.children) && node.children.length)
.map((node) => node.value);
store.setExpanded(valueList);
} else {
store.replaceExpanded(prevExpanded);
prevExpanded = null;
}
});

return {
store,
rebuild,
Expand Down

0 comments on commit 37951bf

Please sign in to comment.