fix(editor): update element.frameId on frame change (#11490)
Co-authored-by: Diego Mateos <dimateos@ucm.es>
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user