container components need `children: true`

This commit is contained in:
Michael Shanks 2020-08-12 16:28:41 +01:00
parent 2db40c6d2c
commit c95363dd66
3 changed files with 7 additions and 5 deletions

View File

@ -48,7 +48,7 @@ export const createProps = (componentDefinition, derivedFromProps) => {
assign(props, derivedFromProps) assign(props, derivedFromProps)
} }
if (componentDefinition.children !== false && isUndefined(props._children)) { if (componentDefinition.children && isUndefined(props._children)) {
props._children = [] props._children = []
} }

View File

@ -18,7 +18,7 @@ describe("createDefaultProps", () => {
expect(props.fieldName).toBeDefined() expect(props.fieldName).toBeDefined()
expect(props.fieldName).toBe("something") expect(props.fieldName).toBe("something")
stripStandardProps(props) stripStandardProps(props)
expect(keys(props).length).toBe(3) expect(keys(props).length).toBe(2)
}) })
it("should set component _component", () => { it("should set component _component", () => {
@ -104,14 +104,13 @@ describe("createDefaultProps", () => {
expect(props._children).toEqual([]) 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 comp = getcomponent()
const { props, errors } = createProps(comp) const { props, errors } = createProps(comp)
expect(errors).toEqual([]) expect(errors).toEqual([])
expect(props._children).toBeDefined() expect(props._children).not.toBeDefined()
expect(props._children).toEqual([])
}) })
it("should not create _children array when children=false ", () => { it("should not create _children array when children=false ", () => {

View File

@ -244,6 +244,7 @@
}, },
"list": { "list": {
"description": "A configurable data list that attaches to your backend models.", "description": "A configurable data list that attaches to your backend models.",
"children": true,
"data": true, "data": true,
"props": { "props": {
"model": "models" "model": "models"
@ -263,6 +264,7 @@
}, },
"recorddetail": { "recorddetail": {
"description": "Loads a record, using an ID in the url", "description": "Loads a record, using an ID in the url",
"children": true,
"data": true, "data": true,
"props": { "props": {
"model": "models" "model": "models"
@ -599,6 +601,7 @@
}, },
"container": { "container": {
"name": "Container", "name": "Container",
"children": true,
"description": "An element that contains and lays out other elements. e.g. <div>, <header> etc", "description": "An element that contains and lays out other elements. e.g. <div>, <header> etc",
"props": { "props": {
"className": "string", "className": "string",