Skip to content

Commit

Permalink
Hide the columns count control on empty columns block (#16476)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jul 15, 2019
1 parent cf1da64 commit c3d80db
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/block-library/src/columns/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (
<>
<InspectorControls>
<PanelBody>
Expand Down Expand Up @@ -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 } />
</div>
Expand Down

0 comments on commit c3d80db

Please sign in to comment.