Skip to content

Button group doesn't easily support adding custom buttons #77839

Closed

Description

@mikeybinns

Description

When you add a custom button block as an allowed child of the buttons block, it doesn't adapt the insert to a pick list. The code is set so it only anticipates a single block, which means it's difficult to add custom blocks (you must rely on transforms which is not ideal).

The buttons block should default to adding a default button if multiple button options are not available, however if the block is changed to support multiple allowed blocks, then it should change to a pop-up style inserter like most of the other blocks.

It should be possible to support this with full backwards compatibility and no change to most users. This change would only affect the edit side as well so it wouldn't require any block deprecation.

I am willing and able to work on this if this is deemed it should be fixed.

Step-by-step reproduction instructions

  1. Create a custom button block (my example is a block with an icon select)
  2. Filter the buttons block to add your block as an allowed block (see code below)
  3. Go to the editor and add a buttons block
  4. Insert a new block and see it only adds a default block and there's no clear way to insert your new block.
add_filter(
	'block_type_metadata',
	function ( $metadata ) {

		if ( isset( $metadata['name'] ) && 'core/buttons' === $metadata['name'] ) {

			if ( empty( $metadata['allowedBlocks'] ) ) {
				$metadata['allowedBlocks'] = array();
			}

			if ( ! in_array( 'namespace/block-name, $metadata['allowedBlocks'], true ) ) {
				$metadata['allowedBlocks'][] = 'namespace/block-name';
			}
		}

		return $metadata;
	}
);

Screenshots, screen recording, code snippet

No response

Environment info

WP 6.9, Gutenberg plugin not installed.

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    on Apr 30, 2026
  2. adithya-naik commented on Apr 30, 2026

    @adithya-naik
    Contributor

    I have reproduced this, and working on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Block] ButtonsAffects the Buttons Block[Status] In ProgressTracking issues with work in progress[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