Skip to content

Commit

Permalink
Render inner blocks in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
DAreRodz authored and ockham committed Apr 25, 2022
1 parent 408c687 commit 441dfb7
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/block-library/src/post-comments/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Warning,
useBlockProps,
store as blockEditorStore,
InnerBlocks,
} from '@wordpress/block-editor';
import { __, sprintf } from '@wordpress/i18n';
import { useSelect } from '@wordpress/data';
Expand All @@ -27,6 +28,7 @@ export default function PostCommentsEdit( {
attributes: { textAlign },
setAttributes,
context: { postType, postId },
clientId,
} ) {
let [ postTitle ] = useEntityProp( 'postType', postType, 'title', postId );
postTitle = postTitle || __( 'Post Title' );
Expand All @@ -44,6 +46,10 @@ export default function PostCommentsEdit( {
.__experimentalDiscussionSettings
);

const innerBlocks = useSelect( ( select ) =>
select( blockEditorStore ).getBlocks( clientId )
);

const isSiteEditor = postType === undefined || postId === undefined;

const postTypeSupportsComments = useSelect( ( select ) =>
Expand Down Expand Up @@ -90,6 +96,10 @@ export default function PostCommentsEdit( {

const disabledRef = useDisabled();

if ( innerBlocks.length > 0 ) {
return <InnerBlocks />;
}

return (
<>
<BlockControls group="block">
Expand Down

0 comments on commit 441dfb7

Please sign in to comment.