Site logo

Archived topic

blocks width after updating to 3.1.3

3 replies · Started by Adrian on February 9, 2022

Viewing posts 1–4 of 4

Hey team,
Just noticed the width of some blocks (preformatted, code, etc) is displayed as full width after updating GP to 3.1.3.
On the post preview page they're OK.
Test on 2 sites already, same issue.
Didn't see this on previous versions

Hi there,

Thanks for the heads up!

Just to confirm, is this only happening with the "Code" block? I'm not able to find any others doing this.

didn't see other block going crazy :)

That's good!

Here's a temporary fix for now until we release 3.1.4. We're going to wait to see if anything else comes up until we release that one.

add_filter( 'block_editor_settings_all', function( $editor_settings ) {
    $content_width = generate_get_block_editor_content_width();

    $spacing_settings = wp_parse_args(
        get_option( 'generate_spacing_settings', array() ),
        generate_spacing_get_defaults()
    );

    $content_width_calc = sprintf(
        'calc(%1$s - %2$s - %3$s)',
        absint( $content_width ) . 'px',
        absint( $spacing_settings['content_left'] ) . 'px',
        absint( $spacing_settings['content_right'] ) . 'px'
    );

    $css = '.block-editor-block-list__layout pre {max-width: ' . $content_width_calc . '}';
    $editor_settings['styles'][] = array( 'css' => $css );

    return $editor_settings;
} );
This archived topic is closed to new replies.