From 8e10304f20266839f7c727c686f0ad1038f8b0a9 Mon Sep 17 00:00:00 2001 From: Ivan Gabriele Date: Wed, 25 Sep 2024 15:07:28 +0200 Subject: [PATCH] fix(fields): handle undefined min/max prop in DateRangePicker number inputs --- src/fields/DateRangePicker/NumberInput.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/fields/DateRangePicker/NumberInput.tsx b/src/fields/DateRangePicker/NumberInput.tsx index ec0014eb7..243eb770f 100644 --- a/src/fields/DateRangePicker/NumberInput.tsx +++ b/src/fields/DateRangePicker/NumberInput.tsx @@ -17,7 +17,7 @@ import type { Promisable } from 'type-fest' export type NumberInputProps = Omit< InputHTMLAttributes, - 'defaultValue' | 'maxLength' | 'onInput' | 'pattern' | 'type' + 'defaultValue' | 'max' | 'maxLength' | 'min' | 'onInput' | 'pattern' | 'type' > & { isLight: boolean max?: number @@ -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