ACF + Sage and guttenberg

Hey folks,

I am using ACF 5.8.0-RC, I have noticed a really strange and unintended behavior happening in my admin panel. It seems that if I use blade files for the acf gutenberg blocks, my main.css file gets enqueued into the head, when it shouldn’t be. Thus, clobbering the UI.

I have tried the using blade files in my blocks via Template helper or using sage-acf-wp-blocks. Not using blade templates does not cause the issue.

My setup file for my scripts/styles looks like

/**
 * Theme assets
 */
add_action('wp_enqueue_scripts', function () {
    wp_enqueue_style('sage/main.css', asset_path('styles/main.css'), false, null); //Styles intended for front end
    wp_enqueue_script('sage/main.js', asset_path('scripts/main.js'), ['jquery'], null, true);
    wp_localize_script('sage/main.js', 'enqueData', array(
        'ajax_url' => admin_url('admin-ajax.php')
    ));
}, 100);

add_action('admin_enqueue_scripts', function () {
    wp_register_style('sage/editor-main.css', \App\asset_path('styles/editor-style.css'), false, '1.0.0'); // styles intended for admin
    wp_enqueue_style('sage/editor-main.css');
});

When I use a block that uses a blade file both the main.scss and main.js are loaded. I would like to understand why that is, and possibly how to prevent it.

Hey, @reagan! Can you share all other related code for at least one of the blocks that causes this, as well as the contents of your config.json?

From what little you’ve shared so far, I’m not sure if it will address the problem, but you could also give https://github.com/mmirus/register-acf-gutenberg-block a shot to see if it makes any difference. Usage examples are available here: https://github.com/mmirus/register-acf-gutenberg-block-examples

This topic was automatically closed after 42 days. New replies are no longer allowed.