@homebound/form-state 2.24.0 → 2.25.0
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.
- package/dist/useFormState.js +6 -1
- package/dist/useFormStates.js +7 -2
- package/package.json +1 -1
package/dist/useFormState.js
CHANGED
|
@@ -39,7 +39,12 @@ function useFormState(opts) {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
// Don't use canSave() because we don't want to set touched for all the fields
|
|
42
|
-
if (autoSaveRef.current && form.dirty &&
|
|
42
|
+
if (autoSaveRef.current && form.dirty && !isAutoSaving) {
|
|
43
|
+
// It's very frustrating to not know why the form is savings, to go ahead and log these
|
|
44
|
+
if (!form.valid) {
|
|
45
|
+
console.debug("Skipping auto-save b/c form is invalid: ", form.errors);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
43
48
|
isAutoSaving = "queued";
|
|
44
49
|
let maybeError;
|
|
45
50
|
// We use setTimeout as a cheap way to wait until the end of the current event listener
|
package/dist/useFormStates.js
CHANGED
|
@@ -35,8 +35,13 @@ function useFormStates(opts) {
|
|
|
35
35
|
const existing = objectStateCache[getId(input)];
|
|
36
36
|
let form = existing === null || existing === void 0 ? void 0 : existing[0];
|
|
37
37
|
async function maybeAutoSave(form) {
|
|
38
|
-
// Don't use canSave() because we don't want to set touched for all the fields
|
|
39
|
-
if (autoSaveRef.current && form.dirty
|
|
38
|
+
// Don't use form.canSave() because we don't want to set touched for all the fields
|
|
39
|
+
if (autoSaveRef.current && form.dirty) {
|
|
40
|
+
// It's very frustrating to not know why the form is savings, to go ahead and log these
|
|
41
|
+
if (!form.valid) {
|
|
42
|
+
console.debug("Skipping auto-save b/c form is invalid: ", form.errors);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
40
45
|
const { current: pending } = pendingAutoSaves;
|
|
41
46
|
if (isAutoSaving) {
|
|
42
47
|
pending.add(form);
|