Skip to content

Registered block styles set to be the default aren't actually set as the default #38890

@skorasaurus

Description

@skorasaurus

Description

You can set what block style is applied (or already selected) when opening a block for first time in the editor.

New Default block styles can be set through register_block_style when is_default parameter set to true;

When registering a block style and setting it to default, the registered block style (blue quote in the example) is not set as the default; the default style included in Gutenberg is still selected.

Step-by-step reproduction instructions

  1. Include this code snippet in your active theme's functions.php
if ( function_exists( 'register_block_style' ) ) {
    register_block_style(
        'core/quote',
        array(
            'name'         => 'blue-quote',
            'label'        => __( 'Blue Quote', 'textdomain' ),
            'is_default'   => true,
            'inline_style' => '.wp-block-quote.is-style-blue-quote { color: blue; }',
        )
    );
}
  1. create a new page/post
  2. add block containing the block style.

Screenshots, screen recording, code snippet

screen recording shows what I describe.
https://user-images.githubusercontent.com/955351/154548693-caf94e52-d847-4f4a-95de-5b424b499edb.mp4

Environment info

  • wordpress 5.9;
  • gutenberg 12.6; twentynineteen theme.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Block APIAPI that allows to express the block paradigm.[Feature] Block Style VariationsIssues or PRs that are related to the style variations for blocks[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions