Skip to content

Commit

Permalink
Fix bug in test input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFarmer committed Mar 8, 2024
1 parent ec59748 commit 04fe3a3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/antd/InputNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,17 @@ export const InputNumber = (props: InputNumberProps): InputNumber => {
return ""
})
const parser = ((value?: string): number => {
if (value !== "" && value !== undefined) {
const isNumeric = value ? !isNaN(Number(value)) : false
if (isNumeric && value !== undefined) {
if (isPercentage) {
return parseFloat(value.replace("%", "")) / 100.0
} else {
return parseFloat(value)
}
}
// this allows us to return undefined for cases where the value has been deleted
// when InputNumber is paired with a Slider, the Slider pointer will disappear
// insetad of jumping to some default value
// when InputNumber is paired with a Slider, the Slider value selector will disappear
// for required fields an error message will show instead of jumping to some default value
return undefined as unknown as number
})

Expand Down

0 comments on commit 04fe3a3

Please sign in to comment.