I use #each to display an input for every member of the tasks
array. When I click the Add task button, a new element is inserted into the array, so a new input appears in the #each loop.
How do I focus the input that's been added upon clicking the Add task button?
<script>
let tasks = [];
function addTask() {
tasks = [...tasks, { title: "" }];
}
</script>
{#each tasks as task}
<input type="text" bind:value={task.title} />
{/each}
<button on:click={addTask}>Add task</button>