Fix issue with text input autofocus and autofocus when creating views

This commit is contained in:
Andrew Kingston 2024-08-23 14:41:05 +01:00
parent a11e2082f9
commit a4fa619dda
No known key found for this signature in database
1 changed files with 6 additions and 3 deletions

View File

@ -1,6 +1,6 @@
<script>
import "@spectrum-css/textfield/dist/index-vars.css"
import { createEventDispatcher, onMount } from "svelte"
import { createEventDispatcher, onMount, tick } from "svelte"
export let value = null
export let placeholder = null
@ -68,10 +68,13 @@
return type === "number" ? "decimal" : "text"
}
onMount(() => {
onMount(async () => {
if (disabled) return
focus = autofocus
if (focus) field.focus()
if (focus) {
await tick()
field.focus()
}
})
</script>