Fix freshly created elbow arrow and bindable interaction

This commit is contained in:
Mark Tolmacs 2025-03-02 15:51:07 +01:00
parent fe58962bfd
commit 2af0336466
2 changed files with 9 additions and 4 deletions

View file

@ -1249,6 +1249,7 @@ const getElbowArrowData = (
...arrow, ...arrow,
type: "arrow", type: "arrow",
elbowed: true, elbowed: true,
type: "arrow",
points: nextPoints, points: nextPoints,
} as ExcalidrawElbowArrowElement, } as ExcalidrawElbowArrowElement,
"start", "start",
@ -1262,6 +1263,7 @@ const getElbowArrowData = (
...arrow, ...arrow,
type: "arrow", type: "arrow",
elbowed: true, elbowed: true,
type: "arrow",
points: nextPoints, points: nextPoints,
} as ExcalidrawElbowArrowElement, } as ExcalidrawElbowArrowElement,
"end", "end",

View file

@ -263,8 +263,10 @@ export class LinearElementEditor {
return null; return null;
} }
const elbowed = isElbowArrow(element);
if ( if (
isElbowArrow(element) && elbowed &&
!linearElementEditor.pointerDownState.lastClickedIsEndPoint && !linearElementEditor.pointerDownState.lastClickedIsEndPoint &&
linearElementEditor.pointerDownState.lastClickedPoint !== 0 linearElementEditor.pointerDownState.lastClickedPoint !== 0
) { ) {
@ -281,7 +283,7 @@ export class LinearElementEditor {
: undefined, : undefined,
].filter((idx): idx is number => idx !== undefined) ].filter((idx): idx is number => idx !== undefined)
: linearElementEditor.selectedPointsIndices; : linearElementEditor.selectedPointsIndices;
const lastClickedPoint = isElbowArrow(element) const lastClickedPoint = elbowed
? linearElementEditor.pointerDownState.lastClickedPoint > 0 ? linearElementEditor.pointerDownState.lastClickedPoint > 0
? element.points.length - 1 ? element.points.length - 1
: 0 : 0
@ -337,6 +339,7 @@ export class LinearElementEditor {
element.x + element.points[pointIndex][0] + deltaX, element.x + element.points[pointIndex][0] + deltaX,
element.y + element.points[pointIndex][1] + deltaY, element.y + element.points[pointIndex][1] + deltaY,
); );
if ( if (
pointIndex === lastClickedPoint && pointIndex === lastClickedPoint &&
(pointIndex === 0 || pointIndex === element.points.length - 1) (pointIndex === 0 || pointIndex === element.points.length - 1)
@ -349,8 +352,8 @@ export class LinearElementEditor {
app.scene.getNonDeletedElements(), app.scene.getNonDeletedElements(),
app.scene.getNonDeletedElementsMap(), app.scene.getNonDeletedElementsMap(),
app.state.zoom, app.state.zoom,
isElbowArrow(element), elbowed,
isElbowArrow(element), elbowed,
); );
if (hoveredElement) { if (hoveredElement) {
const newPoints = Array.from(element.points); const newPoints = Array.from(element.points);