Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

fix(editor): update `element.frameId` on frame change (#11490)

David Luzar069982606dd7
diff --git a/packages/element/src/frame.ts b/packages/element/src/frame.ts
index 7489c3459a..36ebf5ee02 100644
--- a/packages/element/src/frame.ts
+++ b/packages/element/src/frame.ts
@@ -569,10 +569,6 @@ export const addElementsToFrame = <T extends ElementsMapOrArray>(
continue;
}
- if (element.frameId && element.frameId !== frame.id) {
- continue;
- }
-
finalElementsToAdd.add(element);
const boundTextElement = getBoundTextElement(element, elementsMap);
diff --git a/packages/element/tests/frame.test.tsx b/packages/element/tests/frame.test.tsx
index b419d00f02..635a5bc2e9 100644
--- a/packages/element/tests/frame.test.tsx
+++ b/packages/element/tests/frame.test.tsx
@@ -692,6 +692,34 @@ describe("adding elements to frames", () => {
expect(rect2.frameId).toBe(frame.id);
});
+ it("should move an element dragged from one frame into another", () => {
+ const otherFrame = API.createElement({
+ id: "otherFrame",
+ type: "frame",
+ x: 300,
+ y: 0,
+ width: 150,
+ height: 150,
+ });
+ const frameChild = API.createElement({
+ id: "frameChild",
+ type: "rectangle",
+ x: 50,
+ y: 50,
+ width: 20,
+ height: 20,
+ frameId: frame.id,
+ });
+
+ API.setElements([frame, frameChild, otherFrame]);
+
+ expect(frameChild.frameId).toBe(frame.id);
+
+ dragElementIntoFrame(otherFrame, frameChild);
+
+ expect(frameChild.frameId).toBe(otherFrame.id);
+ });
+
it("should layer a dragged element above the highest frame child", () => {
const frameChild = API.createElement({
id: "frameChild",