mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
parent
c851aaaf7b
commit
a04676d423
3 changed files with 51 additions and 2 deletions
|
@ -8472,7 +8472,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||||
this,
|
this,
|
||||||
)
|
)
|
||||||
: unbindLinearElements(
|
: unbindLinearElements(
|
||||||
this.scene.getNonDeletedElements(),
|
this.scene.getSelectedElements(this.state),
|
||||||
elementsMap,
|
elementsMap,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,7 +293,16 @@ export const unbindLinearElements = (
|
||||||
): void => {
|
): void => {
|
||||||
elements.forEach((element) => {
|
elements.forEach((element) => {
|
||||||
if (isBindingElement(element)) {
|
if (isBindingElement(element)) {
|
||||||
bindOrUnbindLinearElement(element, null, null, elementsMap);
|
if (element.startBinding !== null && element.endBinding !== null) {
|
||||||
|
bindOrUnbindLinearElement(element, null, null, elementsMap);
|
||||||
|
} else {
|
||||||
|
bindOrUnbindLinearElement(
|
||||||
|
element,
|
||||||
|
element.startBinding ? "keep" : null,
|
||||||
|
element.endBinding ? "keep" : null,
|
||||||
|
elementsMap,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -369,4 +369,44 @@ describe("element binding", () => {
|
||||||
expect(arrow2.startBinding?.elementId).toBe(container.id);
|
expect(arrow2.startBinding?.elementId).toBe(container.id);
|
||||||
expect(arrow2.endBinding?.elementId).toBe(rectangle1.id);
|
expect(arrow2.endBinding?.elementId).toBe(rectangle1.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// #6459
|
||||||
|
it("should unbind arrow only from the latest element", () => {
|
||||||
|
const rectLeft = UI.createElement("rectangle", {
|
||||||
|
x: 0,
|
||||||
|
width: 200,
|
||||||
|
height: 500,
|
||||||
|
});
|
||||||
|
const rectRight = UI.createElement("rectangle", {
|
||||||
|
x: 400,
|
||||||
|
width: 200,
|
||||||
|
height: 500,
|
||||||
|
});
|
||||||
|
const arrow = UI.createElement("arrow", {
|
||||||
|
x: 210,
|
||||||
|
y: 250,
|
||||||
|
width: 180,
|
||||||
|
height: 1,
|
||||||
|
});
|
||||||
|
expect(arrow.startBinding?.elementId).toBe(rectLeft.id);
|
||||||
|
expect(arrow.endBinding?.elementId).toBe(rectRight.id);
|
||||||
|
|
||||||
|
// Drag arrow off of bound rectangle range
|
||||||
|
const handles = getTransformHandles(
|
||||||
|
arrow,
|
||||||
|
h.state.zoom,
|
||||||
|
arrayToMap(h.elements),
|
||||||
|
"mouse",
|
||||||
|
).se!;
|
||||||
|
|
||||||
|
Keyboard.keyDown(KEYS.CTRL_OR_CMD);
|
||||||
|
const elX = handles[0] + handles[2] / 2;
|
||||||
|
const elY = handles[1] + handles[3] / 2;
|
||||||
|
mouse.downAt(elX, elY);
|
||||||
|
mouse.moveTo(300, 400);
|
||||||
|
mouse.up();
|
||||||
|
|
||||||
|
expect(arrow.startBinding).not.toBe(null);
|
||||||
|
expect(arrow.endBinding).toBe(null);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue