Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form Block: register block style not working #59045

Open
bradhogan opened this issue Feb 15, 2024 · 2 comments
Open

Form Block: register block style not working #59045

bradhogan opened this issue Feb 15, 2024 · 2 comments
Labels
[Block] Form (experimental) Affects the form block [Type] Bug An existing feature does not function as intended

Comments

@bradhogan
Copy link

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' );
  1. Make sure you have Gutenberg > Experiments > form and input blocks checked
  2. Add a new page
  3. Add a form block
  4. Check the custom style in the components panel for the "Dark Background" style
  5. Update
  6. 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

  • wp 6.4.3
  • gutenberg 17.7.0
  • chrome
  • mac

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

@bradhogan bradhogan added the [Type] Bug An existing feature does not function as intended label Feb 15, 2024
@t-hamano t-hamano added the [Block] Form (experimental) Affects the form block label Feb 15, 2024
@t-hamano
Copy link
Contributor

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

@aaronrobertshaw
Copy link
Contributor

I believe this issue will be resolved once #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Form (experimental) Affects the form block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants