Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(widgetsFor): return widgets for variable type lists #7296

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -167,9 +167,28 @@ export class PreviewPane extends React.Component {
const { fields, entry, fieldsMetaData } = this.props;
const field = fields.find(f => f.get('name') === name);
const nestedFields = field && field.get('fields');
const variableTypes = field && field.get('types');
const value = entry.getIn(['data', field.get('name')]);
const metadata = fieldsMetaData.get(field.get('name'), Map());

// Variable Type lists
if (List.isList(value) && variableTypes) {
return value.map(val => {
const valueType = variableTypes.find(t => t.get('name') === val.get('type'));
const typeFields = valueType && valueType.get('fields');
const widgets =
typeFields &&
Map(
typeFields.map((f, i) => [
f.get('name'),
<div key={i}>{this.getWidget(f, val, metadata.get(f.get('name')), this.props)}</div>,
]),
);
return Map({ data: val, widgets });
});
}

// List widgets
if (List.isList(value)) {
return value.map(val => {
const widgets =
Expand Down
Loading