diff --git a/src/routes/(app)/diary/[date]/add-entry/+page.svelte b/src/routes/(app)/diary/[date]/add-entry/+page.svelte index 44a63f9..5b8db39 100644 --- a/src/routes/(app)/diary/[date]/add-entry/+page.svelte +++ b/src/routes/(app)/diary/[date]/add-entry/+page.svelte @@ -29,6 +29,16 @@ let scanLoading = $state(false); let scanError = $state(null); + let searchInput = $state(null); + $effect(() => { if (searchInput) setTimeout(() => searchInput?.focus(), 50); }); + + let gramsInput = $state(null); + $effect(() => { + if (selectedProduct && gramsInput) { + setTimeout(() => gramsInput?.focus(), 50); + } + }); + function handleSearch(value: string) { q = value; clearTimeout(debounceTimer); @@ -113,11 +123,11 @@ handleSearch(e.currentTarget.value)} - autofocus class="w-full bg-zinc-900 border border-zinc-700 rounded-xl pl-9 pr-4 py-2.5 text-sm text-zinc-100 placeholder-zinc-500 focus:outline-none focus:border-green-500 transition-colors" /> @@ -224,6 +234,7 @@ class="w-11 h-11 rounded-xl bg-zinc-800 hover:bg-zinc-700 transition-colors text-lg font-medium flex items-center justify-center" >− (null); + $effect(() => { + if (entry && gramsInput) gramsInput.focus(); + }); + const preview = $derived(entry ? { calories: Math.round(entry.product.calories * grams / 100), protein: Math.round(entry.product.protein * grams / 100 * 10) / 10, @@ -113,12 +118,12 @@ class="w-12 h-12 rounded-xl bg-zinc-900 hover:bg-zinc-800 transition-colors text-xl font-medium flex items-center justify-center" >−