From 9ddad9d8347d6e9fb7c07a093188106e00949cfe Mon Sep 17 00:00:00 2001 From: NeilClack Date: Tue, 7 Jul 2026 22:14:23 -0500 Subject: [PATCH] Fix proclamation form fields not auto-filling on edit Switch from initialized from prop to -synced values so form fields always populate when the record changes. Key the TipTap editor on record.id to force re-render. --- .../proclamations/ProclamationForm.svelte | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/routes/(protected)/admin/proclamations/ProclamationForm.svelte b/src/routes/(protected)/admin/proclamations/ProclamationForm.svelte index 7486f76..d996652 100644 --- a/src/routes/(protected)/admin/proclamations/ProclamationForm.svelte +++ b/src/routes/(protected)/admin/proclamations/ProclamationForm.svelte @@ -32,18 +32,23 @@ if (record.id) dirty = true; } - let name = $state(String(record.name ?? '')); - let solfeggioFrequencyId = $state(String(record.solfeggioFrequencyId ?? '')); - let subscriptionLevelId = $state(String(record.subscriptionLevelId ?? '')); + let name = $state(''); + let solfeggioFrequencyId = $state(''); + let subscriptionLevelId = $state(''); + let parentCategoryId = $state(''); + let categoryId = $state(''); - let parentCategoryId = $state( - String( + $effect(() => { + name = String(record.name ?? ''); + solfeggioFrequencyId = String(record.solfeggioFrequencyId ?? ''); + subscriptionLevelId = String(record.subscriptionLevelId ?? ''); + parentCategoryId = String( record.parentCategoryId ?? (record.category as Record | undefined)?.parentId ?? '' - ) - ); - let categoryId = $state(String(record.categoryId ?? '')); + ); + categoryId = String(record.categoryId ?? ''); + }); let parentOptions = $derived(categories.filter((c) => c.parentId === null)); @@ -56,6 +61,8 @@ parentCategoryId = target.value; categoryId = ''; } + + let contentKey = $derived(record.id ?? 'new');
@@ -200,12 +207,14 @@ > Content -
+
+ {#key record.id} -
+ {/key} +
{#if fieldErrors.content}

{fieldErrors.content}

{/if}