Skip to content

Commit

Permalink
Ensure min/max are piped through number field
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph committed Nov 30, 2023
1 parent cabea63 commit 6950ca1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/components/form/fields/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export const NumberFieldInner = <
required,
id: idProp,
transform,
min,
max,
}: TextFieldProps<number, TFieldValues, TName>) => {
const generatedId = useId()
const id = idProp || generatedId
Expand All @@ -90,6 +92,8 @@ export const NumberFieldInner = <
aria-describedby={description ? `${id}-label-tip` : undefined}
defaultValue={value}
onChange={(v) => onChange(transform ? transform(v) : v)}
minValue={typeof min !== 'undefined' ? Number(min) : undefined}
maxValue={typeof max !== 'undefined' ? Number(max) : undefined}
{...fieldRest}
/>
<ErrorMessage error={error} label={label} />
Expand Down

0 comments on commit 6950ca1

Please sign in to comment.