1
0
Fork 0
mirror of synced 2024-09-21 03:43:21 +12:00

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

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>