diff --git a/CHANGELOG.md b/CHANGELOG.md index c8f5fcef7089..266bb568d5b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `4.0.0`. +- Made `description` prop optional for `EuiDescribedFormGroup` ([#](https://github.com/elastic/eui/pull/)) ## [`4.0.0`](https://github.com/elastic/eui/tree/v4.0.0) diff --git a/src-docs/src/views/form_layouts/described_form_group.js b/src-docs/src/views/form_layouts/described_form_group.js index 8e5c329f3d4d..c9a3967ecd3a 100644 --- a/src-docs/src/views/form_layouts/described_form_group.js +++ b/src-docs/src/views/form_layouts/described_form_group.js @@ -97,6 +97,18 @@ export default class extends Component { + No description} + > + + + + + Multiple fields} titleSize="m" diff --git a/src/components/form/described_form_group/__snapshots__/described_form_group.test.js.snap b/src/components/form/described_form_group/__snapshots__/described_form_group.test.js.snap index de5e412314ba..1cd159b95345 100644 --- a/src/components/form/described_form_group/__snapshots__/described_form_group.test.js.snap +++ b/src/components/form/described_form_group/__snapshots__/described_form_group.test.js.snap @@ -58,6 +58,54 @@ exports[`EuiDescribedFormGroup is rendered 1`] = ` `; +exports[`EuiDescribedFormGroup props description is not rendered when it's not provided 1`] = ` +
+ + + +

+ Title +

+
+
+ + + + + +
+
+`; + exports[`EuiDescribedFormGroup props fullWidth is rendered 1`] = `
+ {description} + + ); + + // If user has defined an aria ID, assume they have passed the ID to + // the form row describedByIds and skip describedby here. + ariaProps['aria-describedby'] = userAriaId ? null : ariaId; + } + return (
{title} - - {description} - + + {renderedDescription} + {children} @@ -100,7 +110,7 @@ EuiDescribedFormGroup.propTypes = { fullWidth: PropTypes.bool, titleSize: PropTypes.oneOf(TITLE_SIZES), title: PropTypes.node.isRequired, - description: PropTypes.node.isRequired, + description: PropTypes.node, idAria: PropTypes.string, }; diff --git a/src/components/form/described_form_group/described_form_group.test.js b/src/components/form/described_form_group/described_form_group.test.js index 8b3648cd75c2..3713f22c87d0 100644 --- a/src/components/form/described_form_group/described_form_group.test.js +++ b/src/components/form/described_form_group/described_form_group.test.js @@ -105,5 +105,21 @@ describe('EuiDescribedFormGroup', () => { expect(component) .toMatchSnapshot(); }); + + test(`description is not rendered when it's not provided`, () => { + const component = shallow( + Title} + > + + + + + ); + + expect(component) + .toMatchSnapshot(); + }); }); });