Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

fix cloning element.points (#744)

David Luzar6dd3620dd699
diff --git a/src/element/newElement.ts b/src/element/newElement.ts
index 314493f2c1..13e37f5d2e 100644
--- a/src/element/newElement.ts
+++ b/src/element/newElement.ts
@@ -65,8 +65,13 @@ export function newTextElement(
export function duplicateElement(element: ReturnType<typeof newElement>) {
const copy = {
...element,
- points: JSON.parse(JSON.stringify(element.points)),
};
+ if ("points" in copy) {
+ copy.points = Array.isArray(element.points)
+ ? JSON.parse(JSON.stringify(element.points))
+ : element.points;
+ }
+
delete copy.shape;
copy.id = nanoid();
copy.seed = randomSeed();