Merge pull request #3768 from strapi/fix/edit-group

Fix bug when editing an existing entry that did not have a group
This commit is contained in:
Alexandre BODIN 2019-08-12 11:18:12 +02:00 committed by GitHub
commit cf3df913e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import React, { useEffect, useReducer, memo } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { get } from 'lodash';
import { get, size } from 'lodash';
import pluginId from '../../pluginId';
import { useEditView } from '../../contexts/EditView';
@ -72,7 +72,7 @@ function Group({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [didCheckErrors]);
const groupValueLength = groupValue.length;
const groupValueLength = size(groupValue);
return (
<>

View File

@ -54,7 +54,9 @@ export const cleanData = (retrievedData, ctLayout, groupLayouts) => {
})
: value;
} else {
cleanedData = recursiveCleanData(value, groupLayouts[group]);
cleanedData = value
? recursiveCleanData(value, groupLayouts[group])
: value;
}
break;
default:

View File

@ -62,7 +62,9 @@ const createYupSchema = (model, { groups }) => {
? yup.array().of(groupSchema)
: groupSchema;
groupSchema =
attribute.required === true ? groupSchema.defined() : groupSchema;
attribute.required === true
? groupSchema.defined()
: groupSchema.nullable();
acc[current] = groupSchema;
}
return acc;