[BUG] Group skin with Elementor V4 (atomic) elements renders without styles

Support › MB Elementor Integrator › [BUG] Group skin with Elementor V4 (atomic) elements renders without styles

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #50284
    Hello DollyHello Dolly
    Participant

    Description

    A group skin (metabox_group_template) whose layout uses Elementor V4 atomic elements (for example an e-flexbox) renders on the front end without the styles of those elements: no background, no padding, nothing that was set on them in the editor. V3 widgets inside the same skin keep their styles.

    Cause

    Elementor enqueues the styles of atomic elements (uploads/elementor/css/local-{post id}-frontend-*.css) only for the documents announced through the elementor/post/render action before it enqueues the page's styles (Atomic_Styles_Manager, on elementor/frontend/after_enqueue_post_styles).

    Elementor Pro announces the templates nested in a rendered document in ElementorPro\Modules\AtomicWidgets\Template_Styles, but it looks only for the settings template_id and alternate_templates. The Meta Box Group widget keeps its skin in mb_skin_template, so the skin is never announced and its atomic styles are never enqueued. The skin is rendered later, inside the widget, through get_builder_content_for_display(), when the styles have already been enqueued.

    Display conditions on the skin do not help: the Theme Builder announces one document per location (single), and that is the single template containing the Group widget.

    Steps to reproduce

    1. Create a group skin, put an e-flexbox in it with a background colour and some padding, and put the Meta Box dynamic widgets inside it.
    2. Use the skin in a Meta Box Group widget on a single template.
    3. Open a post that uses that single template: the group items render, but the flexbox has no background and no padding, and the page links no local-{skin id}-frontend-*.css.

    Workaround

    Announce the skins ourselves, the way Elementor Pro does for template_id:

    
    add_action( 'elementor/post/render', function ( $post_id ) {
        static $seen = [];
        if ( isset( $seen[ $post_id ] ) ) {
            return;
        }
        $seen[ $post_id ] = true;
    
        $data = get_post_meta( $post_id, '_elementor_data', true );
        if ( ! is_string( $data ) || false === strpos( $data, 'mb_skin_template' ) ) {
            return;
        }
    
        preg_match_all( '/"mb_skin_template":"(\d+)"/', $data, $matches );
        foreach ( array_unique( $matches[1] ) as $skin_id ) {
            do_action( 'elementor/post/render', (int) $skin_id );
        }
    }, 20 );
    

    With it the page links local-{skin id}-frontend-*.css and the skin renders as in the editor. It would be better in the plugin itself, possibly also through the elementor/document/related_posts filter, which Elementor uses for the global classes and the cache invalidation of nested documents.

    Environment

    MB Elementor Integrator 2.2.7 (the relevant code is unchanged in 2.2.8), Meta Box 5.15.2, Meta Box Group 1.4.7, Elementor 4.3.5, Elementor Pro 4.3.2.

    #50287
    PeterPeter
    Moderator

    Hello,

    Thanks for the detailed report.

    I can reproduce it with MB Elementor Integrator 2.2.8, Elementor 4.4.0 and Elementor Pro 4.4.0, so newer Elementor versions don't fix it.

    Your analysis is correct. When Elementor Pro looks for nested templates, it only checks template_id, additional_template_select and alternate_templates. Our Group widget stores the skin in mb_skin_template, so the skin never reaches elementor/post/render before the styles are enqueued.

    I also tested your snippet. With it, the skin's CSS file loads and the flexbox renders as it does in the editor, so it's safe to keep using until we release a fix.

    I've passed this to our development team to fix in the plugin, along with your note about the elementor/document/related_posts filter. I'll update you here when it's done.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.