Problem/Motivation
Element::isEmpty()
is used by BlockComponentRenderArray to determine if a block is empty.
However Inline Blocks (and perhaps some complex Views blocks) do not return an empty array when they are empty.
Because it's a rendered entity, it has several keys like #block_content
, #view_mode
, and an empty child array for each field.
Original report:
Custom blocks added through Layout Builder do no have placeholders, while standard blocks do. These placeholders were added a few years ago in issues like
Provide placeholders for empty blocks (for example, an empty Views listing) β
, but this did not make placeholders universal. If you create a custom block type and then add it to a layout, but choose not to display the title, the block is completely invisible to editors. My understanding was that the previous issue was also supposed to add placeholders for views blocks, but my testing shows that views blocks are also lacking these placeholders.
Steps to reproduce
Steps:
Install Layout Builder
Enable Layout Builder for Basic Page (any content type will do, and "Allow each content item to have its layout customized." is not required).
Add an inline block with a title, no body field, and hide the title (uncheck "Display title")
Expectation:
Placeholder for the "Block title" block
shown on page
Actual:
Nothing shown on page. Block still takes up vertical space and contextual links are available.
Proposed resolution
Either improve how "empty" entities are rendered, or improve the checking in BlockComponentRenderArray.
Remaining tasks
Figure out how to fix
User interface changes
The expected text will display
API changes
TBD
Data model changes
N/A
Release notes snippet
TBD