fix: library ids cross-contamination on multiple insert (#6466)

This commit is contained in:
David Luzar 2023-04-16 17:09:51 +02:00 committed by GitHub
parent 034113772d
commit e9064a4a87
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@ import { MIME_TYPES } from "../constants";
import Spinner from "./Spinner";
import LibraryMenuBrowseButton from "./LibraryMenuBrowseButton";
import clsx from "clsx";
import { duplicateElements } from "../element/newElement";
const CELLS_PER_ROW = 4;
@ -96,7 +97,14 @@ const LibraryMenuItems = ({
} else {
targetElements = libraryItems.filter((item) => item.id === id);
}
return targetElements;
return targetElements.map((item) => {
return {
...item,
// duplicate each library item before inserting on canvas to confine
// ids and bindings to each library item. See #6465
elements: duplicateElements(item.elements),
};
});
};
const createLibraryItemCompo = (params: {