From b5fbedd13b9402aa2eb0d3bf2914c8b1f88cb9af Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Tue, 20 Jan 2026 17:09:17 +0100 Subject: [PATCH] fix: use event parameter in CardAdd image selection handler The show_local_image function was using `this.files[0]` which doesn't work in Svelte 5's onchange handlers. Changed to use `event.target.files[0]` to properly access the selected file. This fixes recipe image uploads not working because the file was never being captured from the input element. --- src/lib/components/CardAdd.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/components/CardAdd.svelte b/src/lib/components/CardAdd.svelte index a9b8e46..b1cf476 100644 --- a/src/lib/components/CardAdd.svelte +++ b/src/lib/components/CardAdd.svelte @@ -58,8 +58,9 @@ let upload_error = $state(""); * Handles image file selection and preview * The actual upload will happen when the form is submitted */ -export async function show_local_image(){ - const file = this.files[0]; +export async function show_local_image(event: Event){ + const input = event.target as HTMLInputElement; + const file = input.files?.[0]; if (!file) { console.log('[CardAdd] No file selected'); return;