From 171f06da22cc130363fd6d396fb9a25f3f803778 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 16 Apr 2026 19:14:28 +0200 Subject: [PATCH] fix(#221): reset parent/color/delete state when navigating between tag edit pages SvelteKit reuses the same +page.svelte instance on client-side navigation, so $state() initialisations only run on mount. Add an $effect keyed on data.tag.id to reset parentId, selectedColor and deleteConfirmName whenever the user switches to a different tag in the admin sidebar. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/routes/admin/tags/[id]/+page.svelte | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frontend/src/routes/admin/tags/[id]/+page.svelte b/frontend/src/routes/admin/tags/[id]/+page.svelte index 0bed5324..ad14951c 100644 --- a/frontend/src/routes/admin/tags/[id]/+page.svelte +++ b/frontend/src/routes/admin/tags/[id]/+page.svelte @@ -21,6 +21,16 @@ function getInitialColor() { let parentId = $state(getInitialParentId()); let selectedColor = $state(getInitialColor()); +// SvelteKit reuses the same component instance when navigating between tags client-side. +// $state() only initialises on mount, so we need an effect to reset local form state +// whenever the server switches to a different tag. +$effect(() => { + void data.tag.id; // declare dependency + parentId = data.tag.parentId ?? ''; + selectedColor = data.tag.color ?? ''; + deleteConfirmName = ''; +}); + const colors = [ 'sage', 'sienna',