Closed marcbelletre closed 4 months ago
Do we need both then?
This was inadvertently handled in #224
The default alignment option still does not work with the latest version.
I have a simple Icon
block with the following definition:
<?php
namespace App\Blocks;
use Log1x\AcfComposer\Block;
use StoutLogic\AcfBuilder\FieldsBuilder;
class Icon extends Block
{
/**
* The block name.
*
* @var string
*/
public $name = 'Icon';
/**
* The default block text alignment.
*
* @var string
*/
public $align_text = 'center';
/**
* The default block content alignment.
*
* @var string
*/
public $align_content = 'center';
// ...
When I insert a new Icon block in the editor, the alignment is set to left instead of being centered.
If I switch back to the patch I provided the block is centered as it should be.
Sorry about that, I got confused and thought this change was inside of $supports
which now automatically handles casing.
No problem, thanks for merging!
The default values for
align_text
andalign_content
don't work currently.I figured out that
alignText
andalignContent
attributes are automatically added to the block definition when enabling support for these properties. The values of both properties don't reflect the default values that are set in the Block definition.Let's say we have a simple Block that have centered text and content as default values.
When adding a new block to the editor the defaults are not used.
If I dump the
$block
variable that is passed to therender
function ofsrc/Block.php
I can see thatalignText
andalignContent
are automatically set toleft
andtop
I think this bug has been introduced since ACF 6. According to this thread they have added the camel-case properties to match the block.json format.
There is a comment referencing the same issue but no solution have been provided.
I found out that adding the
alignText
andalignContent
properties to the block settings fixes the issue.