From 9ef748bf2d427e57f53e42259681f65f70744c6f Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 12 Aug 2020 16:28:41 +0100 Subject: [PATCH] container components need `children: true` --- .../components/userInterface/pagesParsing/createProps.js | 2 +- packages/builder/tests/createProps.spec.js | 7 +++---- packages/standard-components/components.json | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/userInterface/pagesParsing/createProps.js b/packages/builder/src/components/userInterface/pagesParsing/createProps.js index de4de1c2a6..7e213f82df 100644 --- a/packages/builder/src/components/userInterface/pagesParsing/createProps.js +++ b/packages/builder/src/components/userInterface/pagesParsing/createProps.js @@ -48,7 +48,7 @@ export const createProps = (componentDefinition, derivedFromProps) => { assign(props, derivedFromProps) } - if (componentDefinition.children !== false && isUndefined(props._children)) { + if (componentDefinition.children && isUndefined(props._children)) { props._children = [] } diff --git a/packages/builder/tests/createProps.spec.js b/packages/builder/tests/createProps.spec.js index bd468ba41a..3759598c1a 100644 --- a/packages/builder/tests/createProps.spec.js +++ b/packages/builder/tests/createProps.spec.js @@ -18,7 +18,7 @@ describe("createDefaultProps", () => { expect(props.fieldName).toBeDefined() expect(props.fieldName).toBe("something") stripStandardProps(props) - expect(keys(props).length).toBe(3) + expect(keys(props).length).toBe(2) }) it("should set component _component", () => { @@ -104,14 +104,13 @@ describe("createDefaultProps", () => { expect(props._children).toEqual([]) }) - it("should create a _children array when children not defined ", () => { + it("should not create a _children array when children not defined ", () => { const comp = getcomponent() const { props, errors } = createProps(comp) expect(errors).toEqual([]) - expect(props._children).toBeDefined() - expect(props._children).toEqual([]) + expect(props._children).not.toBeDefined() }) it("should not create _children array when children=false ", () => { diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index 6836f4981c..ad898accfc 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -244,6 +244,7 @@ }, "list": { "description": "A configurable data list that attaches to your backend models.", + "children": true, "data": true, "props": { "model": "models" @@ -263,6 +264,7 @@ }, "recorddetail": { "description": "Loads a record, using an ID in the url", + "children": true, "data": true, "props": { "model": "models" @@ -599,6 +601,7 @@ }, "container": { "name": "Container", + "children": true, "description": "An element that contains and lays out other elements. e.g.
,
etc", "props": { "className": "string",