Fix parsing of numbers when assigning a default value to a number field
This commit is contained in:
parent
47d19ca9a1
commit
efe6fe15e2
|
@ -2,10 +2,17 @@
|
|||
import StringField from "./StringField.svelte"
|
||||
|
||||
export let defaultValue
|
||||
|
||||
const parseNumber = val => {
|
||||
if (val == null) {
|
||||
return null
|
||||
}
|
||||
return isNaN(val) ? null : parseFloat(val)
|
||||
}
|
||||
</script>
|
||||
|
||||
<StringField
|
||||
{...$$props}
|
||||
type="number"
|
||||
defaultValue={isNaN(defaultValue) ? null : parseFloat(defaultValue)}
|
||||
defaultValue={parseNumber(defaultValue)}
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue