fix: Arrow vanishes when orbit binding to the same element

This commit is contained in:
Mark Tolmacs
2025-10-30 18:47:39 +01:00
parent f4ab372ed6
commit 481296efa9
2 changed files with 34 additions and 26 deletions

View File

@@ -434,6 +434,10 @@ const bindingStrategyForSimpleArrowEndpointDragging = (
mode: "inside",
}
: { mode: null };
other =
finalize && hit && hit.id === oppositeBinding?.elementId
? { mode: null }
: other;
return { current, other };
}

View File

@@ -2220,14 +2220,12 @@ const pointDraggingUpdates = (
const startIsDraggingOverEndElement =
element.endBinding &&
nextArrow.startBinding &&
app.state.bindMode === "inside" &&
endIsDragged &&
startIsDragged &&
nextArrow.startBinding.elementId === element.endBinding.elementId;
const endIsDraggingOverStartElement =
element.startBinding &&
nextArrow.endBinding &&
app.state.bindMode === "inside" &&
startIsDragged &&
endIsDragged &&
element.startBinding.elementId === nextArrow.endBinding.elementId;
// We need to update the non-dragged point too if bound,
@@ -2238,17 +2236,20 @@ const pointDraggingUpdates = (
nextArrow.endBinding.elementId,
)! as ExcalidrawBindableElement)
: null;
const endLocalPoint =
endBindable && !endIsDraggingOverStartElement
? updateBoundPoint(
nextArrow,
"endBinding",
nextArrow.endBinding,
endBindable,
elementsMap,
customIntersector,
) || nextArrow.points[nextArrow.points.length - 1]
: nextArrow.points[nextArrow.points.length - 1];
const endLocalPoint = startIsDraggingOverEndElement
? nextArrow.points[nextArrow.points.length - 1]
: endIsDraggingOverStartElement && app.state.bindMode !== "inside"
? nextArrow.points[0]
: endBindable
? updateBoundPoint(
nextArrow,
"endBinding",
nextArrow.endBinding,
endBindable,
elementsMap,
customIntersector,
) || nextArrow.points[nextArrow.points.length - 1]
: nextArrow.points[nextArrow.points.length - 1];
// We need to keep the simulated next arrow up-to-date, because
// updateBoundPoint looks at the opposite point
@@ -2263,17 +2264,20 @@ const pointDraggingUpdates = (
)! as ExcalidrawBindableElement)
: null;
const startLocalPoint =
startBindable && startIsDraggingOverEndElement
? updateBoundPoint(
nextArrow,
"startBinding",
nextArrow.startBinding,
startBindable,
elementsMap,
customIntersector,
) || nextArrow.points[0]
: nextArrow.points[0];
const startLocalPoint = endIsDraggingOverStartElement
? nextArrow.points[0]
: startIsDraggingOverEndElement && app.state.bindMode !== "inside"
? nextArrow.points[nextArrow.points.length - 1]
: startBindable
? updateBoundPoint(
nextArrow,
"startBinding",
nextArrow.startBinding,
startBindable,
elementsMap,
customIntersector,
) || nextArrow.points[0]
: nextArrow.points[0];
const endChanged =
pointDistance(