Make WordPress Core

Opened 4 weeks ago

Last modified 3 weeks ago

#63580 new defect (bug)

render_block does not render innerblocks when used explicitly

Reported by: yashjawale's profile yashjawale Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: trunk
Component: Editor Keywords: 2nd-opinion
Focuses: Cc:

Description

When using render_blocks explicitly, it doesn't render the nested blocks if they don't have any innerContent defined in them.

I believe this shouldn't be the case as some parent blocks like core/column shouldn't won't necessarily have innerContent when other blocks are present inside them.

For example, this doesn't render the content of the nested paragraph blocks

<?php
$first_column_blocks = [
        [
                'blockName' => 'core/paragraph',
                'attrs' => [],
                'innerBlocks' => [],
                'innerHTML' => '<p>This is the first column demo content.</p>',
                'innerContent' => [
                        '<p>This is the first column demo content.</p>',
                ],
        ],
];

$second_column_blocks = [
        [
                'blockName' => 'core/paragraph',
                'attrs' => [],
                'innerBlocks' => [],
                'innerHTML' => '<p>This is the second column demo content.</p>',
                'innerContent' => [
                        '<p>This is the second column demo content.</p>',
                ],
        ],
];

$column_layout_block = [
        'blockName' => 'core/columns',
        'attrs' => [],
        'innerBlocks' => [
                [
                        'blockName' => 'core/column',
                        'attrs' => [],
                        'innerBlocks' => $first_column_blocks
                ],
                [
                        'blockName' => 'core/column',
                        'attrs' => [],
                        'innerBlocks' => $second_column_blocks
                ],
        ]
];

For markup generated by Gutenberg, there is some innerContent generated hence, it doesn't the same issue. But I don't think a developer is expected to pass this content in explicitly [demonstrated in linked image]

More info present in Gutenberg ticket linked below


This issue was originally reported by Andreas Lindahl as an Issue on Gutenberg repository
https://github.com/WordPress/gutenberg/issues/69307

Attachments (1)

451341949-e21093e1-ffc1-4626-90dd-cf783b633644.png (76.4 KB) - added by yashjawale 4 weeks ago.
innerContent generated by same layout created in Gutenberg editor instead

Download all attachments as: .zip

Change History (4)

@yashjawale
4 weeks ago

innerContent generated by same layout created in Gutenberg editor instead

#1 @yashjawale
4 weeks ago

I've narrowed down the cause to innerContent check in render() method of class-wp-block.php

I'll be happy to work on a patch for this issue if this isn't expected behavior

Ref: https://github.com/yashjawale/wordpress-develop/blob/fc41a79118c10a897e0b29b97d40bea110cebafc/src/wp-includes/class-wp-block.php#L534

This ticket was mentioned in Slack in #core by yash_jawale. View the logs.


4 weeks ago

#3 @yashjawale
3 weeks ago

  • Focuses template removed
  • Keywords 2nd-opinion added
Note: See TracTickets for help on using tickets.