fix: Dedupe boundElement ids when container duplicated with alt+drag (#5938)

* Dedupe boundElement ids when container duplicated with alt+drag and add spec

* set to null by default
This commit is contained in:
Aakansha Doshi 2022-12-01 20:44:33 +05:30 committed by GitHub
parent 66bbfda460
commit a86224c797
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 1 deletions

View file

@ -370,6 +370,10 @@ export const deepCopyElement = (val: any, depth: number = 0) => {
if (depth === 0 && (key === "shape" || key === "canvas")) {
continue;
}
if (key === "boundElements") {
tmp[key] = null;
continue;
}
tmp[key] = deepCopyElement(val[key], depth + 1);
}
}
@ -409,6 +413,7 @@ export const duplicateElement = <TElement extends Mutable<ExcalidrawElement>>(
overrides?: Partial<TElement>,
): TElement => {
let copy: TElement = deepCopyElement(element);
if (isTestEnv()) {
copy.id = `${copy.id}_copy`;
// `window.h` may not be defined in some unit tests