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

Commit 935ef95

Browse files
authored
feat(gui): toggle tree nodes by double-clicking (#985)
feat(gui): expand tree nodes by double-clicking
1 parent 04062d1 commit 935ef95

File tree

1 file changed

+12
-3
lines changed
  • api-editor/gui/src/features/packageData/treeView

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,20 @@ export const TreeNode: React.FC<TreeNodeProps> = function ({
6969
}
7070
};
7171

72+
const [timeoutId, setTimeoutId] = React.useState<NodeJS.Timeout>();
7273
const handleNodeClick = (event: MouseEvent) => {
73-
if (event.shiftKey) {
74+
if (event.detail === 1) {
75+
// Handle single click
76+
const newTimeoutId = setTimeout(() => {
77+
navigate(`/${declaration.id}`);
78+
}, 200);
79+
setTimeoutId(newTimeoutId);
80+
} else if (event.detail === 2) {
81+
// Handle double click
82+
if (timeoutId) {
83+
clearTimeout(timeoutId);
84+
}
7485
toggleExpanded();
75-
} else {
76-
navigate(`/${declaration.id}`);
7786
}
7887
};
7988

0 commit comments

Comments
 (0)