Skip to content

Commit 7bbf8a5

Browse files
committed
fix(MoneyInput): fix value two way binding
1 parent fceb8e0 commit 7bbf8a5

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

components/mdc/TextInput/MoneyInput.svelte

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ let width = ''
2323
let hasFocused = false
2424
let hasBlurred = false
2525
26-
$: mdcTextField.value = value
2726
$: valueLength = value?.toString()?.length
2827
$: hasExceededMaxLength = maxlength && valueLength > maxlength
2928
$: hasExceededMaxValue = maxValue && internalValue > maxValue
@@ -32,7 +31,7 @@ $: showErrorIcon = hasExceededMaxValue || isLowerThanMinValue || hasExceededMaxL
3231
$: error = showErrorIcon || (hasFocused && hasBlurred && required && !internalValue)
3332
$: showCounter = maxlength && valueLength / maxlength > 0.85
3433
$: valueNotDivisibleByStep = internalValue && (internalValue / Number(step)) % 1 !== 0
35-
$: internalValue = Number(value) || ''
34+
$: internalValue = Number(value) || 0
3635
3736
onMount(() => {
3837
mdcTextField = new MDCTextField(element)
@@ -76,7 +75,7 @@ const focus = (node) => autofocus && node.focus()
7675
aria-labelledby={labelID}
7776
aria-controls="{labelID}-helper-id"
7877
aria-describedby="{labelID}-helper-id"
79-
bind:value={internalValue}
78+
bind:value
8079
use:focus
8180
on:focus={() => (hasFocused = true)}
8281
on:blur

0 commit comments

Comments
 (0)