@homebound/form-state 2.2.7 → 2.2.8

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/formState.js CHANGED
@@ -180,7 +180,7 @@ function newObjectState(config, parentState, instance, key, onBlur) {
180
180
  throw new Error(`${key || "formState"} is currently readOnly`);
181
181
  }
182
182
  getFields(this).forEach((field) => {
183
- if (field.key in value && (!field.dirty || !field._focused)) {
183
+ if (field.key in value) {
184
184
  field.set(value[field.key], opts);
185
185
  }
186
186
  });
@@ -329,8 +329,10 @@ function newValueFieldState(parentInstance, parentState, key, rules, isIdKey, is
329
329
  if (this.readOnly && !opts.resetting && !opts.refreshing) {
330
330
  throw new Error(`${key} is currently readOnly`);
331
331
  }
332
- if (opts.refreshing && this.dirty && value !== this.value) {
333
- // Ignore refreshed values if we're already dirty
332
+ if (opts.refreshing && this.dirty && this.value !== value) {
333
+ // Ignore incoming values if we have changes (this.dirty) unless our latest change (this.value)
334
+ // matches the incoming value (value), b/c if it does we should accept it and reset originalValue
335
+ // so that we're not longer dirty.
334
336
  return;
335
337
  }
336
338
  else if (computed && (opts.resetting || opts.refreshing)) {
@@ -931,7 +931,7 @@ describe("formState", () => {
931
931
  // And they have wip edits
932
932
  formState.firstName.set("ff");
933
933
  // When a mutation result sets both firstName and lastName
934
- formState.set({ firstName: "f2", lastName: "l2" });
934
+ formState.set({ firstName: "f2", lastName: "l2" }, { refreshing: true });
935
935
  // Then we don't overwrite the user's WIP work
936
936
  expect(formState.firstName.value).toEqual("ff");
937
937
  expect(formState.lastName.value).toEqual("l2");
@@ -944,7 +944,7 @@ describe("formState", () => {
944
944
  // Given first name is focused, but has not changed
945
945
  formState.firstName.focus();
946
946
  // When a mutation result sets both firstName and lastName
947
- formState.set({ firstName: "f2", lastName: "l2" });
947
+ formState.set({ firstName: "f2", lastName: "l2" }, { refreshing: true });
948
948
  // Then we do update the value
949
949
  expect(formState.firstName.value).toEqual("f2");
950
950
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebound/form-state",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "author": "Homebound",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",