fix: chord page auto-focuses input on first load

fixes #111
This commit is contained in:
2024-04-23 17:46:05 +02:00
parent 19cf0b26b3
commit 8b2bc6d109

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import { tick } from "svelte";
import { onMount, tick } from "svelte";
import { changes, ChangeType } from "$lib/undo-redo";
import type { ChordInfo } from "$lib/undo-redo";
import { scale } from "svelte/transition";
@@ -11,6 +11,12 @@
export let chord: ChordInfo;
onMount(() => {
if (chord.phrase.length === 0) {
box.focus();
}
});
function keypress(event: KeyboardEvent) {
if (event.key === "ArrowUp") {
addSpecial(event);
@@ -103,7 +109,6 @@
<div
on:keydown={keypress}
on:mousedown={clickCursor}
autofocus={chord.phrase.length === 0}
role="textbox"
tabindex="0"
bind:this={box}