WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.51k stars 4.2k forks source link

Form Block: register block style not working #59045

Open bradhogan opened 9 months ago

bradhogan commented 9 months ago

Description

The register block style option appears but when checked, the class is not applied to the form block.

Step-by-step reproduction instructions

  1. Add the following to your functions.php:

    // REGISTER BLOCK STYLES
    function yourtheme_register_block_styles() {
    register_block_style(
        'core/form',
        array(
            'name'         => 'dark-background',
            'label'        => __( 'Dark Background', 'yourtheme' )
        )
    );
    }
    add_action( 'init', 'yourtheme_register_block_styles' );
  2. Make sure you have Gutenberg > Experiments > form and input blocks checked

  3. Add a new page

  4. Add a form block

  5. Check the custom style in the components panel for the "Dark Background" style

  6. Update

  7. View source in front-end and notice the wp-block-form does not also include is-style-dark-background

Screenshots, screen recording, code snippet

No response

Environment info

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

t-hamano commented 9 months ago

Thanks for the report. I believe this issue will be resolved once #55755 is merged.

aaronrobertshaw commented 9 months ago

I believe this issue will be resolved once https://github.com/WordPress/gutenberg/pull/55755 is merged.

@t-hamano is correct.

The registration of the block style variation is still working as evidenced by it showing up as an option in the UI. The problem is the form block hardcoded a class name into its saved markup preventing the application of the custom block style. It is that problem that will be fixed by #55755.