Skip to content

Commit

Permalink
Block Library: Render Column block with ButtonBlockAppender
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed May 8, 2019
1 parent cdfb97c commit 0442276
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions packages/block-library/src/column/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { InnerBlocks, BlockControls, BlockVerticalAlignmentToolbar } from '@word
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';

const ColumnEdit = ( { attributes, updateAlignment } ) => {
function ColumnEdit( {
attributes,
updateAlignment,
hasChildBlocks,
} ) {
const { verticalAlignment } = attributes;

const classes = classnames( 'block-core-columns', {
Expand All @@ -27,17 +31,29 @@ const ColumnEdit = ( { attributes, updateAlignment } ) => {
value={ verticalAlignment }
/>
</BlockControls>
<InnerBlocks templateLock={ false } />
<InnerBlocks
templateLock={ false }
renderAppender={ (
hasChildBlocks ?
undefined :
() => <InnerBlocks.ButtonBlockAppender />
) }
/>
</div>
);
};
}

export default compose(
withSelect( ( select, { clientId } ) => {
const { getBlockRootClientId } = select( 'core/editor' );
withSelect( ( select, ownProps ) => {
const { clientId } = ownProps;
const {
getBlockRootClientId,
getBlockOrder,
} = select( 'core/block-editor' );

return {
parentColumnsBlockClientId: getBlockRootClientId( clientId ),
hasChildBlocks: getBlockOrder( clientId ).length > 0,
};
} ),
withDispatch( ( dispatch, { clientId, parentColumnsBlockClientId } ) => {
Expand Down

0 comments on commit 0442276

Please sign in to comment.