fix store reactivity with getter/setter

fields was losing reactivity when passed to child components.
use getter/setter to maintain proxy reference.
This commit is contained in:
Justin Edmund 2025-12-11 19:04:17 -08:00
parent 640a0d1c19
commit b7b5b4b4e3

View file

@ -46,11 +46,16 @@ export function createProjectFormStore(initialProject?: Project | null) {
} }
return { return {
// State is returned directly - it's already reactive in Svelte 5 // Use getters to maintain reactivity when accessing state from outside the store
// Components can read: formStore.fields.title get fields() {
// Mutation should go through methods below for validation return fields
fields, },
validationErrors, set fields(value: ProjectFormData) {
fields = value
},
get validationErrors() {
return validationErrors
},
isDirty, isDirty,
// Methods for controlled mutation // Methods for controlled mutation