Browse Source

Fix freshly created elbow arrow and bindable interaction

Mark Tolmacs 6 months ago
parent
commit
2af0336466
2 changed files with 9 additions and 4 deletions
  1. 2 0
      packages/element/src/elbowArrow.ts
  2. 7 4
      packages/element/src/linearElementEditor.ts

+ 2 - 0
packages/element/src/elbowArrow.ts

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

+ 7 - 4
packages/element/src/linearElementEditor.ts

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