@classic-homes/theme-svelte 0.1.22 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -75,6 +75,8 @@ export function usePersistedForm(options) {
|
|
|
75
75
|
let draftRestored = $state(false);
|
|
76
76
|
let lastSubmitTime = $state(0);
|
|
77
77
|
let debounceTimer = null;
|
|
78
|
+
// Store original initialValues for reset (before draft merge)
|
|
79
|
+
const originalInitialValues = JSON.parse(JSON.stringify(initialValues));
|
|
78
80
|
/**
|
|
79
81
|
* Load draft from localStorage
|
|
80
82
|
*/
|
|
@@ -200,9 +202,14 @@ export function usePersistedForm(options) {
|
|
|
200
202
|
});
|
|
201
203
|
/**
|
|
202
204
|
* Extended reset that also clears the draft
|
|
205
|
+
* Resets to original initialValues (not draft-merged values)
|
|
203
206
|
*/
|
|
204
207
|
function reset() {
|
|
208
|
+
// First reset the base form (clears errors, isSubmitted, dirtyFields)
|
|
205
209
|
baseForm.reset();
|
|
210
|
+
// Then overwrite data with original initialValues (not the draft-merged ones)
|
|
211
|
+
// We modify the data object directly to avoid triggering markDirty
|
|
212
|
+
Object.assign(baseForm.data, JSON.parse(JSON.stringify(originalInitialValues)));
|
|
206
213
|
draftRestored = false;
|
|
207
214
|
clearDraft();
|
|
208
215
|
}
|