From c3d80db1c79f8bda8a44dcdf924bee8cc4b03b9a Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Mon, 15 Jul 2019 10:55:03 +0100 Subject: [PATCH] Hide the columns count control on empty columns block (#16476) --- packages/block-library/src/columns/edit.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/block-library/src/columns/edit.js b/packages/block-library/src/columns/edit.js index d573500cd551d9..d798f9f2115cb6 100644 --- a/packages/block-library/src/columns/edit.js +++ b/packages/block-library/src/columns/edit.js @@ -135,9 +135,14 @@ export function ColumnsEdit( { [ `are-vertically-aligned-${ verticalAlignment }` ]: verticalAlignment, } ); + // The template selector is shown when we first insert the columns block (count === 0). + // or if there's no template available. + // The count === 0 trick is useful when you use undo/redo. + const showTemplateSelector = ( count === 0 && ! forceUseTemplate ) || ! template; + return ( <> - { template && ( + { ! showTemplateSelector && ( <> @@ -170,9 +175,7 @@ export function ColumnsEdit( { setForceUseTemplate( true ); } } __experimentalAllowTemplateOptionSkip - // setting the template to null when the inner blocks - // are empty allows to reset to the placeholder state. - template={ count === 0 && ! forceUseTemplate ? null : template } + template={ showTemplateSelector ? null : template } templateLock="all" allowedBlocks={ ALLOWED_BLOCKS } />