fix: input not set min or max null value blur would set null (#2361)

This commit is contained in:
Joel 2024-02-02 18:08:49 +08:00 committed by GitHub
parent 5a004ae429
commit f95839c785
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -26,12 +26,14 @@ const Input: FC<InputProps> = ({
max, max,
}) => { }) => {
const toLimit = (v: string) => { const toLimit = (v: string) => {
if (min !== undefined && parseFloat(v) < min) { const minNum = parseFloat(`${min}`)
const maxNum = parseFloat(`${max}`)
if (!isNaN(minNum) && parseFloat(v) < minNum) {
onChange(`${min}`) onChange(`${min}`)
return return
} }
if (max !== undefined && parseFloat(v) > max) if (!isNaN(maxNum) && parseFloat(v) > maxNum)
onChange(`${max}`) onChange(`${max}`)
} }
return ( return (