From 9237cba1211e514da1f20dc9ef863e040ee33fc9 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 22 Feb 2021 11:37:34 +0200 Subject: [PATCH] do not render Section if children render nothing --- .../components/preferences-modal/section.js | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/edit-post/src/components/preferences-modal/section.js b/packages/edit-post/src/components/preferences-modal/section.js index 6e8ad792878c85..db2b7a04e087ff 100644 --- a/packages/edit-post/src/components/preferences-modal/section.js +++ b/packages/edit-post/src/components/preferences-modal/section.js @@ -1,15 +1,24 @@ -const Section = ( { description, title, children } ) => ( -
-

- { title } -

- { description && ( -

- { description } -

- ) } - { children } -
-); +/** + * WordPress dependencies + */ +import { renderToString } from '@wordpress/element'; + +const Section = ( { description, title, children } ) => { + const content = renderToString( children ); + if ( ! content ) return null; + return ( +
+

+ { title } +

+ { description && ( +

+ { description } +

+ ) } + { children } +
+ ); +}; export default Section;