Skip to content

Commit

Permalink
Fix bug if missing linked item
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmi committed May 13, 2024
1 parent 2c97087 commit d6af915
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/lib/board/Items/useItemActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,9 @@ const useItemActions = () => {
});

insertItems(itemsWithPosition, beforeId);

updateItemExtent();
placeItems(itemsToInsert.map((item) => item.id));
},
[getCenter, insertItems, updateItemExtent]
[getCenter, insertItems, placeItems]
);

const pushItem = React.useCallback(
Expand Down
21 changes: 13 additions & 8 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,19 @@ const getLinkedItemsRecursive = (itemMap, itemIds, alreadyMet = null) => {
return [];
} else {
alreadyMet.add(itemId);
return [
itemId,
...getLinkedItemsRecursive(
itemMap,
itemMap[itemId].linkedItems,
alreadyMet
),
];
if (itemMap[itemId]) {
// If the item has been removed but not from linked list
return [
itemId,
...getLinkedItemsRecursive(
itemMap,
itemMap[itemId].linkedItems,
alreadyMet
),
];
} else {
return [];
}
}
})
.flat();
Expand Down

0 comments on commit d6af915

Please sign in to comment.