Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 566ba8f

Browse files
authored
fix(gui): properly collapse subtree in tree view (#681)
1 parent 5e98938 commit 566ba8f

File tree

1 file changed

+11
-2
lines changed
  • api-editor/gui/src/features/packageData/treeView

1 file changed

+11
-2
lines changed

api-editor/gui/src/features/packageData/treeView/TreeNode.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
HeatMapMode,
1010
selectHeatMapMode,
1111
selectIsExpandedInTreeView,
12+
setAllCollapsedInTreeView,
1213
toggleIsExpandedInTreeView,
1314
} from '../../ui/uiSlice';
1415
import { VisibilityIndicator } from './VisibilityIndicator';
@@ -60,16 +61,24 @@ export const TreeNode: React.FC<TreeNodeProps> = function ({
6061

6162
const fontWeight = filter.shouldKeepDeclaration(declaration, annotations, usages) ? 'bold' : undefined;
6263

64+
const toggleExpanded = () => {
65+
if (showChildren) {
66+
dispatch(setAllCollapsedInTreeView([...declaration.descendantsOrSelf()].map((d) => d.id)));
67+
} else {
68+
dispatch(toggleIsExpandedInTreeView(declaration.id));
69+
}
70+
};
71+
6372
const handleNodeClick = (event: MouseEvent) => {
6473
if (event.shiftKey) {
65-
dispatch(toggleIsExpandedInTreeView(declaration.id));
74+
toggleExpanded();
6675
} else {
6776
navigate(`/${declaration.id}`);
6877
}
6978
};
7079

7180
const handleVisibilityIndicatorClick = (event: MouseEvent) => {
72-
dispatch(toggleIsExpandedInTreeView(declaration.id));
81+
toggleExpanded();
7382
event.stopPropagation();
7483
};
7584

0 commit comments

Comments
 (0)