Skip to content

Commit

Permalink
fix(getRichTextAndBlocksFields): check if subField is an object befor…
Browse files Browse the repository at this point in the history
…e using in operator
  • Loading branch information
Mickaël Depardon committed Feb 14, 2025
1 parent e474c8e commit db044e0
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import isArray from 'lodash/isArray';
import last from 'lodash/last';
import isObject from 'lodash/isObject';
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import pull from 'lodash/pull';
Expand Down Expand Up @@ -42,7 +42,13 @@ export const getRichTextAndBlocksFields = (contentType, components, modifiedData
// Collect dynamic zones from the content-type
Object.entries(modifiedData).forEach(([fieldName, fieldValue]) => {
if (isArray(fieldValue)) {
const isComponentField = fieldValue.some((subField) => '__component' in subField);
const isComponentField = fieldValue.some((subField) => {
if(isObject(subField)) {
return '__component' in subField;
}

return false;
});
if (isComponentField) dynamicZones.push(fieldName);
}
});
Expand Down

0 comments on commit db044e0

Please sign in to comment.