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

Automatically set reusable to false when a block has a parent defined #35223

Closed
fabiankaegy opened this issue Sep 29, 2021 · 8 comments · Fixed by #66158
Closed

Automatically set reusable to false when a block has a parent defined #35223

fabiankaegy opened this issue Sep 29, 2021 · 8 comments · Fixed by #66158
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) Needs Dev Ready for, and needs developer efforts [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@fabiankaegy
Copy link
Member

fabiankaegy commented Sep 29, 2021

What problem does this address?

When a block defines a parent that means that it gets hidden from the inserter unless you are trying to insert it into the defined parent. The block also cannot be moved outside of the container. However, it is still possible to select the "child" block and make it reusable. You can circumvent this by setting reusable to false but I think that should be the default behavior when a block has a parent defined.

What is your proposed solution?

The possible solution for this would be to automatically set the reusable flag to false by default for when a block has a parent defined.

@fabiankaegy fabiankaegy added the [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) label Sep 29, 2021
@gziolo gziolo added [Feature] Block API API that allows to express the block paradigm. [Type] New API New API to be used by plugin developers or package users. [Type] Enhancement A suggestion for improvement. and removed [Type] New API New API to be used by plugin developers or package users. labels Oct 5, 2021
@gziolo
Copy link
Member

gziolo commented Oct 5, 2021

So you are proposing that all block types that have a parent or multiple parents explicitly defined should never be set as reusable blocks. I tend to agree with that. @WordPress/gutenberg-core, what do you think?

@mtias
Copy link
Member

mtias commented Oct 5, 2021

I'm inclined to agree.

@fabiankaegy
Copy link
Member Author

@gziolo I would love it to not be as strict. I think that it would be a great default and I cannot currently see any examples where you would want it. But that doesn't mean there isn't one.

So if we can make it work in a way where the developer could still set reusable to true explicitly to override the default value I think that would be the most flexible solution.

@aristath
Copy link
Member

aristath commented Oct 5, 2021

Seems like a good idea... but being able to override the default would be great and there would be no downsides to doing it.
There are some cases where I can imagine it would make perfect sense to have a child as a reusable block

@gziolo
Copy link
Member

gziolo commented Oct 5, 2021

being able to override the default would be great and there would be no downsides to doing it.
There are some cases where I can imagine it would make perfect sense to have a child as a reusable block

I bet we don't check the context when inserting a reusable block so that's a related area that needs further improvements. To ensure that the reusable block can be inserted only in the place where the outer block would be. To give an example, if the Button block has parent set as the Buttons block and you make Button reusable, then you should be able to insert it only inside the Buttons block.

@jordesign
Copy link
Contributor

@fabiankaegy @gziolo checking with the both of you to see if this is something worth pursuing still?

@gziolo gziolo added the Needs Dev Ready for, and needs developer efforts label Oct 31, 2023
@gziolo
Copy link
Member

gziolo commented Oct 31, 2023

Yes, it is still a valid issue, and it looks like we agreed on the way to address it. It shouldn't be that much work to implement it so maybe it could even be a candidate for a Good First Issue.

@vipul0425
Copy link
Contributor

vipul0425 commented Oct 16, 2024

Hi @fabiankaegy, @gziolo I have created a PR for this issue. Let me know if anything needs to be updated.
Thanks 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Synced Patterns Related to synced patterns (formerly reusable blocks) Needs Dev Ready for, and needs developer efforts [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants