We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0bfe779 commit a3b2299Copy full SHA for a3b2299
1 file changed
anycode/hooks/useFileTree.ts
@@ -249,7 +249,18 @@ export const useFileTree = () => {
249
}, []);
250
251
const clearFileSelection = useCallback(() => {
252
+ const hasSelection = (nodes: TreeNode[]): boolean => {
253
+ for (const node of nodes) {
254
+ if (node.isSelected) return true;
255
+ if (node.children && hasSelection(node.children)) return true;
256
+ }
257
+ return false;
258
+ };
259
+
260
setFileTree((prevTree) => {
261
+ if (!hasSelection(prevTree)) {
262
+ return prevTree;
263
264
const clearSelection = (nodes: TreeNode[]): TreeNode[] => {
265
return nodes.map((node) => {
266
const updatedChildren = node.children ? clearSelection(node.children) : undefined;
0 commit comments