diff --git a/dev-test/config.yml b/dev-test/config.yml index 26f27a07..3a7ebac4 100644 --- a/dev-test/config.yml +++ b/dev-test/config.yml @@ -124,6 +124,7 @@ collections: # A list of collections the CMS should be able to edit - label: 'Object' name: 'object' widget: 'object' + collapsed: true fields: - label: 'Related Post' name: 'post' diff --git a/packages/netlify-cms-widget-object/src/ObjectControl.js b/packages/netlify-cms-widget-object/src/ObjectControl.js index f0c3a459..4c666ea2 100644 --- a/packages/netlify-cms-widget-object/src/ObjectControl.js +++ b/packages/netlify-cms-widget-object/src/ObjectControl.js @@ -42,7 +42,7 @@ export default class ObjectControl extends React.Component { constructor(props) { super(props); this.state = { - collapsed: false, + collapsed: props.field.get('collapsed', false), }; } diff --git a/website/content/docs/widgets/object.md b/website/content/docs/widgets/object.md index 2b5fb325..e8dbc829 100644 --- a/website/content/docs/widgets/object.md +++ b/website/content/docs/widgets/object.md @@ -10,6 +10,7 @@ The object widget allows you to group multiple widgets together, nested under a - **Data type:** list of child widget values - **Options:** - `default`: you can set defaults within each sub-field's configuration + - `collapsed`: if added and labeled `true`, the widget's content is collapsed by default - `fields`: (**required**) a nested list of widget fields to include in your widget - **Example:** ```yaml @@ -27,6 +28,7 @@ The object widget allows you to group multiple widgets together, nested under a - label: "Address" name: "address" widget: "object" + collapsed: true fields: - {label: "Street Address", name: "street", widget: "string"} - {label: "City", name: "city", widget: "string"}