@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.
@@ -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 && form.valid && !isAutoSaving) {
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
@@ -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 && form.valid) {
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/form-state",
3
- "version": "2.24.0",
3
+ "version": "2.25.0",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",