Skip to content

Commit

Permalink
fix(ui): duplicating a folder errors out with "TypeError: Cannot set …
Browse files Browse the repository at this point in the history
…properties of undefined (setting '...')"
  • Loading branch information
flawiddsouza committed Mar 12, 2024
1 parent 4b45922 commit 096ac20
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/ui/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1102,11 +1102,13 @@ export function findItemInTreeById(array, id) {
return result
}

export function generateNewIdsForTreeItemChildren(treeItem, oldIdNewIdMapping) {
export function generateNewIdsForTreeItemChildren(treeItem, oldIdNewIdMapping = null) {
const parentId = treeItem._id
treeItem.children.forEach(item => {
const newId = nanoid()
oldIdNewIdMapping[item._id] = newId
if(oldIdNewIdMapping !== null) {
oldIdNewIdMapping[item._id] = newId
}
item._id = newId
item.parentId = parentId
if('children' in item) {
Expand Down

0 comments on commit 096ac20

Please sign in to comment.