Skip to content

Commit d19f438

Browse files
authored
Radius Rounding Bug (#153)
* round value on sliders * prevent people from typing non-numbers into the text box * limit figure in maxVal
1 parent 742b455 commit d19f438

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/components/InputSwitch/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const InputSwitch = (props: InputSwitchProps): JSX.Element => {
4949
}
5050
if (typeof value == "number") {
5151
value = value * conversion;
52+
value = Number(value.toFixed(4));
5253
}
5354
return value;
5455
}, [getCurrentValue, id, min, conversion, dataType]);
@@ -67,6 +68,7 @@ const InputSwitch = (props: InputSwitchProps): JSX.Element => {
6768
if (typeof value === "number") {
6869
// Convert back to original units for updating recipe object
6970
value = value / conversion;
71+
value = Number(value.toFixed(4));
7072
}
7173
updateRecipeObj(selectedRecipeId, { [id]: value });
7274
};
@@ -76,7 +78,8 @@ const InputSwitch = (props: InputSwitchProps): JSX.Element => {
7678
const numericValue =
7779
typeof value === "number" ? value : Number(value) || 0;
7880
const step = dataType === "integer" ? 1 : 0.01;
79-
const maxValue = (max ?? 1) * conversion;
81+
let maxValue = (max ?? 1) * conversion;
82+
maxValue = Number(maxValue.toFixed(4));
8083

8184
return (
8285
<div className="input-switch">
@@ -100,6 +103,7 @@ const InputSwitch = (props: InputSwitchProps): JSX.Element => {
100103
style={{ margin: "0 6px" }}
101104
value={numericValue}
102105
onChange={handleInputChange}
106+
type="number"
103107
/>
104108
{unit && <span>{unit}</span>}
105109
</div>

0 commit comments

Comments
 (0)