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

Block Directory: Fix metadata of new innerBlocks of a installed block not propagated to the editor #69438

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

karthikeya-io
Copy link

@karthikeya-io karthikeya-io commented Mar 5, 2025

What?

Closes #69315

Why?

PR fixes the Block Directory installation bug which causes failing registration of innerBlocks of newly installed block until the page is refreshed.

How?

When a new block is installed propagating all registered blocks metadata to the editor instead of just newly installed block.

The ideal case would be propagating only new block and innerBlocks used in that block, but I am unable to achieve it.

Testing Instructions

  1. Open new post or page
  2. Open block inserter
  3. Search 'Slider' find "Slider" block by Lovro Hrust and install it
  4. Confirm the block is present without showing error message for innerBlock (makeiteasy/slide).

Testing Instructions for Keyboard

Screenshots or screencast

Before After
image image

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Mar 5, 2025
Copy link

github-actions bot commented Mar 5, 2025

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @karthikeya-io! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@karthikeya-io karthikeya-io changed the title Block Directory: Fix metadata of new innerBlocks of newly installed block not propagated to the editor Block Directory: Fix metadata of new innerBlocks of a installed block not propagated to the editor Mar 5, 2025
@karthikeya-io karthikeya-io marked this pull request as ready for review March 5, 2025 14:41
Copy link

github-actions bot commented Mar 5, 2025

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: karthikeya-io <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: Lovor01 <[email protected]>
Co-authored-by: Rishit30G <[email protected]>

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

@Mamaduka Mamaduka added [Type] Bug An existing feature does not function as intended [Feature] Block Directory Related to the Block Directory, a repository of block plugins labels Mar 5, 2025
@@ -103,23 +104,32 @@ export const installBlockType =
'variations',
];
await apiFetch( {
path: addQueryArgs( `/wp/v2/block-types/${ name }`, {
path: addQueryArgs( `/wp/v2/block-types/`, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fetch all registered block types and bootstrap them again. We need to find a solution that only targets the installed block and its dependencies (inner blocks).

Maybe this could use the allowedBlocks metadata, clearly defining parent/child relation. cc @Lovor01

P.S. As far as I know, the block directory currently doesn't allow block bundle plugins; it only allows single surpose or parent/child blocks. See: https://developer.wordpress.org/plugins/wordpress-org/block-specific-plugin-guidelines/#:~:text=Block%20plugins%20may%20contain%20more%20than%20one%20block%20where%20a%20clearly%20necessary%20parent/child%20or%20container/content%20dependency%20exists%3B%20for%20example%20a%20list%20block%20that%20contains%20list%20item%20blocks.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would fetch all registered block types and bootstrap them again. We need to find a solution that only targets the installed block and its dependencies (inner blocks).

Maybe this could use the allowedBlocks metadata, clearly defining parent/child relation. cc @Lovor01

P.S. As far as I know, the block directory currently doesn't allow block bundle plugins; it only allows single surpose or parent/child blocks. See: https://developer.wordpress.org/plugins/wordpress-org/block-specific-plugin-guidelines/#:~:text=Block%20plugins%20may%20contain%20more%20than%20one%20block%20where%20a%20clearly%20necessary%20parent/child%20or%20container/content%20dependency%20exists%3B%20for%20example%20a%20list%20block%20that%20contains%20list%20item%20blocks.

True; Make IT Easy slider provides two blocks, parent slider and child slide. Slide block has parent setting, see:
https://github.com/Lovor01/makeiteasy-slider/blob/main/src/slide/block.json

@Lovor01
Copy link
Contributor

Lovor01 commented Mar 5, 2025

@karthikeya-io thanks for this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Block not working properly after installing it from inserter
3 participants