Skip to content

Commit

Permalink
fix(fields): handle undefined min/max prop in DateRangePicker number …
Browse files Browse the repository at this point in the history
…inputs
  • Loading branch information
ivangabriele committed Sep 25, 2024
1 parent a2bd958 commit 8e10304
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fields/DateRangePicker/NumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { Promisable } from 'type-fest'

export type NumberInputProps = Omit<
InputHTMLAttributes<HTMLInputElement>,
'defaultValue' | 'maxLength' | 'onInput' | 'pattern' | 'type'
'defaultValue' | 'max' | 'maxLength' | 'min' | 'onInput' | 'pattern' | 'type'
> & {
isLight: boolean
max?: number
Expand Down Expand Up @@ -107,7 +107,11 @@ function NumberInputWithRef(
}

const valueAsNumber = Number(inputRef.current.value)
if (Number.isNaN(valueAsNumber) || valueAsNumber < min || valueAsNumber > max) {
if (
Number.isNaN(valueAsNumber) ||
(min !== undefined && valueAsNumber < min) ||
(max !== undefined && valueAsNumber > max)
) {
onFormatError(true)

return
Expand Down

0 comments on commit 8e10304

Please sign in to comment.