Skip to content

Commit

Permalink
fix: respect min/max for freeform input in number field
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Jan 10, 2025
1 parent 3e91adc commit 715710a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/core/components/AutoField/fields/DefaultField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ export const DefaultField = ({
value={typeof value === "undefined" ? "" : value.toString()}
onChange={(e) => {
if (field.type === "number") {
onChange(Number(e.currentTarget.value));
const numberValue = Number(e.currentTarget.value);

if (typeof field.min !== "undefined" && numberValue < field.min) {
return;
}

if (typeof field.max !== "undefined" && numberValue > field.max) {
return;
}

onChange(numberValue);
} else {
onChange(e.currentTarget.value);
}
Expand Down

0 comments on commit 715710a

Please sign in to comment.