Skip to content

Commit dbf54ce

Browse files
committed
bug: fixed issue where moving DraggableVertices when the formula is invalid breaks the app
1 parent f0e6f97 commit dbf54ce

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

components/core/CreateShape.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,14 @@ const CreateShape = (props) => {
278278
yValue = values.substring(values.indexOf("px") + 2).trim();
279279
}
280280

281+
if (!(xValue.includes("px") || xValue.includes("%")) || xValue.includes(" ")) {
282+
xValue = "0%";
283+
}
284+
285+
if (!(yValue.includes("px") || yValue.includes("%")) || yValue === "") {
286+
yValue = "0%";
287+
}
288+
281289
return {
282290
"x": xValue,
283291
"y": yValue,
@@ -308,7 +316,7 @@ const CreateShape = (props) => {
308316
xValue = Math.round((x / 280.0) * 100.0) + "%";
309317
yValue = Math.round((y / 280.0) * 100.0) + "%";
310318
} else {
311-
319+
312320
// Determines whether previous x coordinate was in percentage or px and adjusts value to maintain same unit of measurement
313321
if (shapeInformation.verticeCoordinates[number].x.includes("%")) {
314322
xValue = Math.round((x / 280.0) * 100.0) + "%";

0 commit comments

Comments
 (0)