Fix InputNumberCal component to handle empty string input correctly and streamline value handling in the InputNumber component for improved data entry experience.
This commit is contained in:
parent
bde1d5b896
commit
8cb2bea2d3
@ -76,7 +76,7 @@ const InputNumberCal = ({
|
|||||||
const next = e.target.value
|
const next = e.target.value
|
||||||
setExprValue(next)
|
setExprValue(next)
|
||||||
const num = parseFloat(next)
|
const num = parseFloat(next)
|
||||||
if (!next) {
|
if (next === '') {
|
||||||
onChange?.(null)
|
onChange?.(null)
|
||||||
} else if (!next.match(/[+\-*/=]/) && !Number.isNaN(num)) {
|
} else if (!next.match(/[+\-*/=]/) && !Number.isNaN(num)) {
|
||||||
onChange?.(num)
|
onChange?.(num)
|
||||||
@ -142,11 +142,11 @@ const InputNumberCal = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<InputNumber
|
<InputNumber
|
||||||
value={value}
|
{...commonProps}
|
||||||
|
value={value != null ? value : null}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
onKeyDown={handleNumberKeyDown}
|
onKeyDown={handleNumberKeyDown}
|
||||||
{...commonProps}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user