fix: add safe check for arrow points length in tranformToExcalidrawElements (#7863)

* fix: add safe check for arrow points length in tranformToExcalidrawElements

* add spec

* throw error only for dev mode

* fix lint
This commit is contained in:
Aakansha Doshi 2024-04-09 09:56:21 +05:30 committed by GitHub
parent 8a162a4cb4
commit a33a400f01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 721 additions and 39 deletions

View file

@ -405,11 +405,21 @@ const bindLinearElementToElement = (
}
}
// Safe check to early return for single point
if (linearElement.points.length < 2) {
return {
linearElement,
startBoundElement,
endBoundElement,
};
}
// Update start/end points by 0.5 so bindings don't overlap with start/end bound element coordinates.
const endPointIndex = linearElement.points.length - 1;
const delta = 0.5;
const newPoints = cloneJSON(linearElement.points) as [number, number][];
// left to right so shift the arrow towards right
if (
linearElement.points[endPointIndex][0] >