Skip to content

Commit 5fce809

Browse files
committed
feat: fixed issue where form values reset when changing shape type
1 parent c3f0d3d commit 5fce809

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

components/core/CreateShape.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,33 +128,35 @@ const CreateShape = (props) => {
128128

129129
if (value === "polygon") {
130130
setShapeInformation({
131-
...initialState,
131+
...shapeInformation,
132+
"formula": "polygon(10% 10%, 90% 10%, 90% 90%, 10% 80%)",
133+
"vertices": 4,
134+
"edges": 4,
132135
});
133136
}
134137

135138
if (value === "circle") {
136139
setShapeInformation({
137-
...shapeInformation,
138-
"type": "circle",
139-
"formula": "circle(50% at 50% 50%)",
140+
...shapeInformation,
141+
"type": "circle",
142+
"formula": "circle(50% at 50% 50%)",
140143
});
141144
}
142145

143146
if (value === "ellipse") {
144147
setShapeInformation({
145-
...shapeInformation,
146-
"type": "ellipse",
147-
"formula": "ellipse(25% 40% at 50% 50%)",
148+
...shapeInformation,
149+
"type": "ellipse",
150+
"formula": "ellipse(25% 40% at 50% 50%)",
148151
});
149152
}
150153

151154
setShapeInformation(prevState => {
152155
return {
153-
...prevState,
154-
"clipPathType": value,
155-
"edges": value === "polygon" ? 4 : 0,
156-
"vertices": value === "polygon" ? 4 : 0,
157-
"notes": "",
156+
...prevState,
157+
"clipPathType": value,
158+
"edges": value === "polygon" ? 4 : 0,
159+
"vertices": value === "polygon" ? 4 : 0,
158160
}
159161
});
160162
return;
@@ -334,7 +336,8 @@ const CreateShape = (props) => {
334336
toast.error('OOPS!! We hit a bummer. Please try again.');
335337
}
336338

337-
} else { // Creating Shape
339+
// Creating Shape
340+
} else {
338341

339342
// Create the shape in the DB
340343
const insertShape = await harperFetch({

0 commit comments

Comments
 (0)