Skip to content

core/button variations doesn't appear in core/buttons inserter #53498

@petitphp

Description

@petitphp

Description

Variation of core/button block are not available in the core/buttons inserter.

I expect to see the variations when adding button.

Step-by-step reproduction instructions

  1. Add the code snippet provided below to WordPress
  2. Create or edit a post
  3. Add a "Buttons" block

Only the basic block "button" is available, the variations can't be used.

  1. Open the browser devtools
  2. In the console, run wp.blocks.getBlockVariations('core/button');

The two registered variations are correctly listed as a result.

Screenshots, screen recording, code snippet

Small code snippet to demonstrate the issue.

<?php
add_action( 'enqueue_block_editor_assets', function () {
	wp_enqueue_script( 'wp-blocks', );
	wp_add_inline_script(
		'wp-blocks',
		"
        wp.blocks.registerBlockVariation('core/button', {
            name: 'custom-button',
            label: 'My custom button',
            attributes: {className: 'my-custom-button'},
        });
        
        wp.blocks.registerBlockVariation('core/button', {
            name: 'custom-button-default',
            label: 'My custom button (Default variation)',
            attributes: {className: 'my-custom-button-default'},
            isDefault: true
        });
        ",
        'after'
	);
} );

Environment info

  • WordPress 6.3, Gutenberg 16.4.0, TwentyTwentyThree
  • Firefox / Chrome
  • Desktop mac 13

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions