Reviewed & tested by the community
Project:
Drupal core
Version:
main
Component:
layout_builder.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Aug 2026 at 19:44 UTC
Updated:
19 Aug 2026 at 14:28 UTC
Jump to comment: Most recent
Comments
Comment #3
clayfreemanTest should demonstrate the failure scenario.
Ready for review.
Comment #4
scontzen commentedThanks @clayfreeman for the clear issue summary and for including a test that demonstrates the failure.
Element::isEmpty()is the same check thatBlockComponentRenderArrayuses to decide whether a block is empty, so both places now use the same definition of empty. I also checked the cacheability handling: keeping the metadata of the empty$viewmeans the empty result gets invalidated correctly once the field has a value again, and the non-empty and exception paths behave as before.I ran the new test locally on PHP 8.5: it passes with the fix and fails without it, the same result as the test-only job in the pipeline. I also reproduced the bug manually with the Blank test formatter: without the fix the block renders as an empty area in the preview, with the fix the placeholder appears.
One small thing that can be fixed on commit: the docblock of the test formatter reads "An blank field formatter" instead of "A blank field formatter".
The fix also changes the live page: the block no longer renders as an empty wrapper there. Maybe worth a second assertion in the test?
Comment #5
clayfreemanAddressed the typo highlighted in #4, also adjusted the label of the field created during the test ("field block" vs "block field").
Comment #6
clayfreemanComment #7
clayfreemanI'd argue against it; this is just a consequence of how block plugins work, and it's already being tested elsewhere (
\Drupal\Tests\block\Kernel\BlockViewBuilderTest::testEmptyRender()).Comment #8
scontzen commentedThanks, that makes sense. The section rendering path is covered as well:
BlockComponentRenderArrayTesthastestOnBuildRenderEmptyBuild()andtestOnBuildRenderEmptyBuildWithCacheTags(), both for the non-preview case. They assert that an empty block build results in an empty component build and that the cache metadata is kept. So the live page doesn't need an extra assertion here.I also compared 7b0dfac8 with the state I reviewed in #4. The changes only touch the test (the docblock typo and the field label), the fix itself is unchanged, and the pipeline is green. The RTBC from #4 still stands.