Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,25 @@ describe("Paragraphs phrases", () => {
]);
});
ff.reset();

it("should handle empty arrays gracefully without runtime errors", () => {
const model = ParagraphsModel.create({
name: "phrases",
value: "$emptyPhrases"
});
const store = MockStore.create({
paragraphs: model
});

// Set empty array in task data
store.task.dataObj = { emptyPhrases: [] };

// Should not throw any errors when updating
expect(() => {
model.updateValue(store);
}).not.toThrow();

// Value should be set to the empty array
expect(model._value).toEqual([]);
});
});
2 changes: 1 addition & 1 deletion web/libs/editor/src/tags/object/Paragraphs/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ const ParagraphsLoadingModel = types.model().actions((self) => ({

if (!Array.isArray(val)) {
errors.push("Provided data is not an array");
} else {
} else if (val.length > 0) {
if (!(self.namekey in val[0])) {
errors.push(`"${self.namekey}" field not found in task data; check your <b>nameKey</b> parameter`);
}
Expand Down
Loading