Skip to content

Commit

Permalink
Hide appender on BlockPreviews via checking for null component in Blo…
Browse files Browse the repository at this point in the history
…ckListAppender (#16887)
  • Loading branch information
getdave authored and gziolo committed Aug 29, 2019
1 parent 9ae860f commit 2a91a84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ function BlockListAppender( {
return null;
}

// A render prop has been provided, use it to render the appender.
// If a render prop has been provided
// use it to render the appender.
if ( CustomAppender ) {
return (
<div className="block-list-appender">
Expand All @@ -36,6 +37,11 @@ function BlockListAppender( {
);
}

// a false value means, don't render any appender.
if ( CustomAppender === false ) {
return null;
}

// Render the default block appender when renderAppender has not been
// provided and the context supports use of the default appender.
if ( canInsertDefaultBlock ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function BlockPreview( { blocks, settings, className, isScaled } ) {
value={ castArray( blocks ) }
settings={ settings }
>
<BlockList />
<BlockList renderAppender={ false } />
</BlockEditorProvider>
</Disabled>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/inner-blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ If locking is not set in an `InnerBlocks` area: the locking of the parent `Inner
If the block is a top level block: the locking of the Custom Post Type is used.

### `renderAppender`
* **Type:** `Function`
* **Default:** - `undefined`. When `renderAppender` is not specific the `<DefaultBlockAppender>` component is as a default. It automatically inserts whichever block is configured as the default block via `wp.blocks.setDefaultBlockName` (typically `paragraph`).
* **Type:** `Function|false`
* **Default:** - `undefined`. When `renderAppender` is not specific the `<DefaultBlockAppender>` component is as a default. It automatically inserts whichever block is configured as the default block via `wp.blocks.setDefaultBlockName` (typically `paragraph`). If a `false` value is provider, no appender is rendered.

A 'render prop' function that can be used to customize the block's appender.

Expand Down

0 comments on commit 2a91a84

Please sign in to comment.