fix elbow segment indexing

This commit is contained in:
Ryan Di 2025-04-25 11:09:18 +10:00
parent f99fe54797
commit 900ee41d0f

View file

@ -583,17 +583,18 @@ export const switchShapes = (
if (isElbowArrow(element)) { if (isElbowArrow(element)) {
const nextPoints = convertLineToElbow(element); const nextPoints = convertLineToElbow(element);
if (nextPoints.length < 2) {
// skip if not enough points to form valid segments
continue;
}
const fixedSegments: FixedSegment[] = []; const fixedSegments: FixedSegment[] = [];
for (let i = 0; i < nextPoints.length - 1; i++) { for (let i = 0; i < nextPoints.length - 1; i++) {
fixedSegments.push({ fixedSegments.push({
start: nextPoints[i], start: nextPoints[i],
end: nextPoints[i + 1], end: nextPoints[i + 1],
index: i, index: i + 1,
}); });
} }
const updates = updateElbowArrowPoints( const updates = updateElbowArrowPoints(
element, element,
app.scene.getNonDeletedElementsMap(), app.scene.getNonDeletedElementsMap(),