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 {
// State is returned directly - it's already reactive in Svelte 5
// Components can read: formStore.fields.title
// Mutation should go through methods below for validation
fields,
validationErrors,
// Use getters to maintain reactivity when accessing state from outside the store
get fields() {
return fields
},
set fields(value: ProjectFormData) {
fields = value
},
get validationErrors() {
return validationErrors
},
isDirty,
// Methods for controlled mutation