fix(element): don't skip placing arrows listed by elements they aren't bound to

Placing skeleton bound arrows skips arrows already updated through another
element, but marked every arrow an element's `boundElements` listed as
updated, though `updateBoundElements()` only updates those bound to it. A
stale entry on an element placed earlier kept the arrow from being placed.

Claude Opus 5.5 (xhigh)
This commit is contained in:
dwelle committed 2026-10-22 15:20:32 +02:00
1 parent a9b2d28782
commit fdc8262d5a
2 files changed
+50 -1

No files matched your search

@@ -1293,4 +1293,47 @@ describe("Test Transform", () => {
expect(frame.y).toBeLessThanOrEqual(minY);
expect(frame.y + frame.height).toBeGreaterThanOrEqual(maxY);
});
it("should place bound arrows listed by elements they aren't bound to", () => {
const convert = (stale: boolean) =>
convertToExcalidrawElements(
[
// lists the arrow without it being bound to it
...(stale
? [
{
type: "rectangle" as const,
id: "X",
x: 0,
y: 300,
boundElements: [{ id: "arrow", type: "arrow" as const }],
},
]
: []),
{ type: "rectangle", id: "A", x: 0, y: 0, width: 100, height: 100 },
{ type: "rectangle", id: "B", x: 400, y: 0, width: 100, height: 100 },
{
type: "arrow",
id: "arrow",
x: 100,
y: 50,
points: [
pointFrom<LocalPoint>(0, 0),
pointFrom<LocalPoint>(300, 0),
],
start: { id: "A" },
end: { id: "B" },
},
],
opts,
).find((element) => element.id === "arrow")!;
const arrow = convert(true);
expect(arrow).toMatchObject({
x: convert(false).x,
width: convert(false).width,
});
// placed off A by the binding gap
expect(arrow.x).toBeGreaterThan(100);
});
});
+7 -1
View File
@@ -865,7 +865,13 @@ export const convertToExcalidrawElements = (
});
arrows.forEach(({ id }) => {
const arrow = boundScene.getNonDeletedElement(id);
if (arrow) {
// only those actually bound to it, which it updated
if (
arrow &&
isArrowElement(arrow) &&
(arrow.startBinding?.elementId === element.id ||
arrow.endBinding?.elementId === element.id)
) {
updatedArrows.push(arrow);
}
});