Unable to disable Gutenberg core block styles

Created on 24 August 2020, almost 4 years ago
Updated 20 May 2024, about 1 month ago

I have tried to disable the core styles for the Button component in the editor and add my own default classes.

I implemented the following JS code:

wp.domReady( () => {
	wp.blocks.unregisterBlockStyle(
		'core/button',
		[ 'default', 'outline', 'squared', 'fill' ]
	);

	wp.blocks.registerBlockStyle(
		'core/button',
		[
			{
				name: 'primary',
				label: 'Primary one',
				isDefault: true,
			},
		]
	);
} );

This gives weird results because the unregisterBlockStyle function is found but it doesn't do anything. The registerBlockStyle function works fine and the new style is added.

Running the same unregisterBlockStyle JS code in browser console removes the buttons correctly.

🐛 Bug report
Status

Closed: works as designed

Component

Code

Created by

🇫🇮Finland HeikkiY Oulu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024