Fix parsing of numbers when assigning a default value to a number field
This commit is contained in:
parent
eaaee33906
commit
c0ca68cb83
|
@ -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