Open MadtownLems opened 10 months ago
This is a known problem. get_block_wrapper_attributes
is not supported in the editor, only for front-end output, so should only be used in if ( ! $is_preview ) {
The reason for this is blocks aren't rendered with the the full context of the page and render location which is required for get_block_wrapper_attributes
.
For most users, this isn't an issue, as blocks in the editor view will have these attributes automatically added to their container editor by WordPress, and most users will want that $is_preview
check anyway for backend previews, to avoid things like padding or margin being applied twice.
For the first preview, that is rendered in the full page context by our cache system, which is why it "seems" to work for preloading.
Describe the bug When using get_block_wrapper_attributes() to generate classes and style attributes for a block based with ACF, the function works as expected when you first open the editor to a Post that contains an ACF block.
Example block output from a basic debugging block (when first opening the editor):
Here's the same block's debugging output after simply toggling a Select field in the right hand toolbar:
To Reproduce Steps to reproduce the behavior:
Expected behavior The block's markup should include the classes from get_block_wrapper_attributes, just as it does when you first edit a page
Code block.json
from block-template.php
Version Information: