Skip to content

Commit

Permalink
Post Template Block: Move inner blocks container to separate component
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewserong committed Nov 3, 2021
1 parent 3797b97 commit 5678a1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/block-library/src/post-template/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ const TEMPLATE = [
[ 'core/post-date' ],
[ 'core/post-excerpt' ],
];

function PostTemplateInnerBlocks() {
const innerBlocksProps = useInnerBlocksProps( {}, { template: TEMPLATE } );
return <li { ...innerBlocksProps } />;
}

export default function PostTemplateEdit( {
clientId,
context: {
Expand Down Expand Up @@ -125,7 +131,6 @@ export default function PostTemplateEdit( {
[ `columns-${ columns }` ]: hasLayoutFlex,
} ),
} );
const innerBlocksProps = useInnerBlocksProps( {}, { template: TEMPLATE } );

if ( ! posts ) {
return (
Expand All @@ -149,7 +154,7 @@ export default function PostTemplateEdit( {
>
{ blockContext ===
( activeBlockContext || blockContexts[ 0 ] ) ? (
<li { ...innerBlocksProps } />
<PostTemplateInnerBlocks />
) : (
<li>
<BlockPreview
Expand Down

0 comments on commit 5678a1d

Please sign in to comment.