You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Adjacent dynamic blocks that render empty leave whitespace in their parent container #80667
I tried replicating the issue on my local, however, for me, no block was added when there were no tags available, let me know if I am missing something:
Thanks @prachigarg19 for testing! I also dug into it a little bit and asked AI for help. I manually tested and can confirm that the issue does not occur when the Tags block is on its own. It occurs when it is accompanied by another empty sibling block, in my case, an empty Categories block.
Here is what AI found:
The Post Terms render callback itself behaves correctly. When no terms exist, it returns an empty string:
Add two Post Tags blocks as direct children of that Group.
Alternatively, use a Categories block and a Tags block, but both must render empty.
Ensure the queried post has no matching terms.
Add the following Additional CSS to the Group:
&:empty {
display: none;
}
Inspect the Group on the frontend.
Both Post Terms blocks correctly render an empty string. However, the \n\n inserted between the sibling blocks during serialization remains inside the Group:
<divclass="wp-block-group ..."></div>
The remaining whitespace text node means that the Group is not considered empty, so :empty does not match.
With only one Post Tags block, no separator between sibling blocks is generated, which explains why the issue does not reproduce in your test.
I reproduced this with the same environment as the issue:
WordPress 7.0.2
Gutenberg 23.6.0
So, more precisely, the Tags block itself does not appear to render a space. The whitespace comes from the serialization of multiple sibling blocks and remains after those dynamic blocks render an empty string. This may therefore be a more general issue affecting adjacent empty dynamic blocks rather than the Post Tags block specifically.
changed the title [-]Post Tags: Block renders space character, even when no tag is available[/-][+]Adjacent dynamic blocks that render empty leave whitespace in their parent container[/+]on Jul 24, 2026
Activity
prachigarg19 commentedon Jul 24, 2026
I tried replicating the issue on my local, however, for me, no block was added when there were no tags available, let me know if I am missing something:
Tested with version 7.1
hanneslsm commentedon Jul 24, 2026
Thanks @prachigarg19 for testing! I also dug into it a little bit and asked AI for help. I manually tested and can confirm that the issue does not occur when the Tags block is on its own. It occurs when it is accompanied by another empty sibling block, in my case, an empty Categories block.
Here is what AI found:
[-]Post Tags: Block renders space character, even when no tag is available[/-][+]Adjacent dynamic blocks that render empty leave whitespace in their parent container[/+]