@homebound/form-state 2.5.1 → 2.5.2
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 +1 -1
- package/dist/formState.test.js +17 -0
- package/package.json +1 -1
package/dist/formState.js
CHANGED
|
@@ -512,7 +512,7 @@ function newListFieldState(parentInstance, parentState, key, rules, listConfig,
|
|
|
512
512
|
this.rows.forEach((r) => {
|
|
513
513
|
r.save();
|
|
514
514
|
});
|
|
515
|
-
originalCopy = parentInstance[key];
|
|
515
|
+
originalCopy = [...(parentInstance[key] || [])];
|
|
516
516
|
_tick.value++;
|
|
517
517
|
},
|
|
518
518
|
ensureSet() {
|
package/dist/formState.test.js
CHANGED
|
@@ -1145,6 +1145,23 @@ describe("formState", () => {
|
|
|
1145
1145
|
expect(formState.books.rows[1].isNewEntity).toBeTruthy();
|
|
1146
1146
|
expect(formState.books.isNewEntity).toBeFalsy();
|
|
1147
1147
|
});
|
|
1148
|
+
it("can properly evaluate dirty lists after calling 'save'", () => {
|
|
1149
|
+
// Given an empty list state
|
|
1150
|
+
const a1 = createAuthorInputState({ books: [] });
|
|
1151
|
+
expect(a1.books.dirty).toBeFalsy();
|
|
1152
|
+
// When adding a book
|
|
1153
|
+
a1.books.add({ title: "t2" });
|
|
1154
|
+
// Then the list state is dirty
|
|
1155
|
+
expect(a1.books.dirty).toBeTruthy();
|
|
1156
|
+
// When saving the form state
|
|
1157
|
+
a1.save();
|
|
1158
|
+
// Then the list is no longer dirty
|
|
1159
|
+
expect(a1.books.dirty).toBeFalsy();
|
|
1160
|
+
// When adding a new book
|
|
1161
|
+
a1.books.add({ title: "t3" });
|
|
1162
|
+
// The list is again dirty
|
|
1163
|
+
expect(a1.books.dirty).toBeTruthy();
|
|
1164
|
+
});
|
|
1148
1165
|
});
|
|
1149
1166
|
class ObservableObject {
|
|
1150
1167
|
constructor() {
|