Render block preview when add the block

Support MB Blocks Render block preview when add the block

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #31270
    SASSAS
    Participant

    Hi all,

    Whenever i add a block, it displays the block as "Enter content in the block settings on the right side".

    Once changed a setting it loads the preview correctly. Is there a way render the preview right away when adding the block to the builder without touching the settings?

    I have blocks without any settings (fields) as well as blocks with settings and it would be nice to render the preview right away with the default settings or if the block hasn't any settings at all.

    #31273
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The extension MB Blocks only supports rendering the block after typing something to the custom field. I will inform the development team to consider supporting this case in future updates.

    #31277
    Matt VMatt V
    Participant

    +1 for this. It does make custom MB blocks seem a bit clumsy next to blocks from other libraries.

    #32165
    hello@logicdesign.co.uk[email protected]
    Participant

    Quick/dirty work around for this would be to just use the mb_blocks_preview JS callback.

    e.g.

    
        function init__container(e)
        {
            console.log('init container');
            console.log($(e.target));
    
            if ( $(e.target).find('> .components-placeholder').length > 0 ) {
                setTimeout(() => { 
                    $('.mb-block-edit select, .mb-block-edit input').trigger('change')
                }, 1000);
            }
        }
    
        $(document).on('mb_blocks_preview/odin-container', init__container);
    
    #34534
    Aaron KesslerAaron Kessler
    Participant

    I would also like to see this happen.

    Default values on custom fields in a block, are preventing the block from rendering, unless the default value is changed, which is a bad user experience on the Gutenberg Editor.

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