@bindu-dashing/dam-solution-v2 5.8.18 → 5.8.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,6 +42,20 @@ const AiOutlineSortDescendingbtn = AiOutlineSortDescending;
42
42
  const AiOutlineSortAscendingbtn = AiOutlineSortAscending;
43
43
  const GrSortIcon = FaShuffle;
44
44
  const IoIosSearchIcon = IoIosSearch;
45
+ // ✅ Helper to find a folder by ID in the tree
46
+ const findFolderById = (tree, folderId) => {
47
+ for (const node of tree) {
48
+ if (node._id === folderId) {
49
+ return node;
50
+ }
51
+ if (isArray(node.children)) {
52
+ const found = findFolderById(node.children, folderId);
53
+ if (found)
54
+ return found;
55
+ }
56
+ }
57
+ return null;
58
+ };
45
59
  // ✅ Helper to insert children into the correct folder recursively
46
60
  const insertSubfolders = (tree, parentId, childrenToInsert) => {
47
61
  console.log('## insertSubfolders', tree, parentId, childrenToInsert);
@@ -113,11 +127,21 @@ function FolderTree({ currentRootId, expandedKeys, selectedKeys, handleExpand, s
113
127
  }
114
128
  else {
115
129
  setFolders((prev) => {
116
- const cloned = cloneDeep(prev);
117
- console.log('## cloned', cloned, fid);
118
- const sorted = sortFoldersRecursively(newFolders, "name", sortOrder);
119
- console.log('## sorted', sorted, insertSubfolders(cloned, fid, sorted));
120
- return insertSubfolders(cloned, fid, sorted);
130
+ // Find the folder with fid in the tree
131
+ const foundFolder = findFolderById(prev, fid);
132
+ if (foundFolder) {
133
+ // Return only the folder with fid and its updated children
134
+ const sorted = sortFoldersRecursively(newFolders, "name", sortOrder);
135
+ console.log('## Found folder:', foundFolder._id, 'New children:', sorted);
136
+ return [Object.assign(Object.assign({}, foundFolder), { children: sorted })];
137
+ }
138
+ else {
139
+ // If folder not found, update the entire tree (fallback)
140
+ console.log('## Folder not found, updating entire tree');
141
+ const cloned = cloneDeep(prev);
142
+ const sorted = sortFoldersRecursively(newFolders, "name", sortOrder);
143
+ return insertSubfolders(cloned, fid, sorted);
144
+ }
121
145
  });
122
146
  }
123
147
  setState((prevState) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bindu-dashing/dam-solution-v2",
3
- "version": "5.8.18",
3
+ "version": "5.8.19",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.0.1",
6
6
  "@emoji-mart/data": "^1.2.1",