Skip to content

Commit

Permalink
Rm error message, convert to int instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan committed Oct 14, 2024
1 parent 99f2270 commit ac780b4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Components/Form/FormFields/RangeFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ export default function RangeFormField(props: Props) {
if (value > max) {
return `Value must be lesser than or equal to ${max}${unit?.label ?? ""}.`;
}

if (props.allowIntegersOnly && Math.abs(value % 1) != 0) {
return `Value must be an integer, cannot use decimals.`;
}
})();

const valueDescription =
Expand All @@ -98,7 +94,10 @@ export default function RangeFormField(props: Props) {
sliderDelta) *
100;

const handleChange = (v: number) => field.handleChange(unit.inversionFn(v));
const handleChange = (v: number) =>
field.handleChange(
unit.inversionFn(props.allowIntegersOnly ? Math.round(v) : v),
);

const displayValue = value != null ? properRoundOf(value) : "";

Expand Down

0 comments on commit ac780b4

Please sign in to comment.