packages/bbui/src/Form/Core/TextField.svelte

This commit is contained in:
Dean 2022-05-16 11:30:20 +01:00
parent 2a1ef4c87f
commit ef333f14d1
1 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
<script> <script>
import "@spectrum-css/textfield/dist/index-vars.css" import "@spectrum-css/textfield/dist/index-vars.css"
import { createEventDispatcher } from "svelte" import { createEventDispatcher, onMount } from "svelte"
export let value = null export let value = null
export let placeholder = null export let placeholder = null
@ -20,11 +20,6 @@
let field let field
let focus = false let focus = false
$: if (autofocus === true && field) {
focus = true
field.focus()
}
const updateValue = newValue => { const updateValue = newValue => {
if (readonly) { if (readonly) {
return return
@ -66,6 +61,11 @@
updateValue(event.target.value) updateValue(event.target.value)
} }
} }
onMount(() => {
focus = autofocus
if (focus) field.focus()
})
</script> </script>
<div <div