Skip to content

Fix: Buttons block shows inserter picker when multiple allowed blocks are registered#77858

Open
adithya-naik wants to merge 1 commit intoWordPress:trunkfrom
adithya-naik:fix/buttons-block-multiple-allowed-blocks-#77839
Open

Fix: Buttons block shows inserter picker when multiple allowed blocks are registered#77858
adithya-naik wants to merge 1 commit intoWordPress:trunkfrom
adithya-naik:fix/buttons-block-multiple-allowed-blocks-#77839

Conversation

@adithya-naik
Copy link
Copy Markdown
Contributor

What

Fixes Buttons block not showing inserter picker when multiple allowed blocks are registered.

Why

The current logic only checks for core/button variations and ignores multiple allowed block types, so it always inserts the default button.

How

Update directInsert logic:

directInsert: !hasButtonVariations && !hasMultipleAllowedBlocks;

Result

  • Single block → direct insert (no change)
  • Multiple blocks → shows inserter picker
image

Testing

  1. Add a custom button block
  2. Allow it inside core/buttons
  3. Click ➕ inside Buttons block

Picker should appear.

Issue

Fixes #77839

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 30, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adithya-naik <adithyanaik@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: mikeybinns <mikeybinns@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Apr 30, 2026
@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Block] Buttons Affects the Buttons Block labels May 1, 2026
@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented May 1, 2026

Thanks for working on this, @adithya-naik!

I think we can remove the directInsert setting in this case + all useSelect logic. The appender already has all this info and will automatically derive the direct insertion conditions. That's exactly what the inline comment suggested as an improvement, which is now already in place.

P.S. Rebasing on top of the trunk should resolve the failing e2e test.

@Mamaduka
Copy link
Copy Markdown
Member

Mamaduka commented May 1, 2026

Okay, it seems there's a minor issue with copying attributes when directInsert isn't specified, but that doesn't change the fix for the Buttons block.

We'll need to fix the attributes to copy the issue first and then land this. @stokesman, I think you were already working on it - #54409. Do you have time to continue work on that PR? I can also take over and handle it.

@adithya-naik
Copy link
Copy Markdown
Contributor Author

adithya-naik commented May 1, 2026

Thanks for the clarification!

You can take it up and merge it @Mamaduka , and then we can proceed with merging this PR.

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

Labels

[Block] Buttons Affects the Buttons Block [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button group doesn't easily support adding custom buttons

2 participants