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

Add ability to restrict block to only be used once within inner blocks area #38958

Open
fabiankaegy opened this issue Feb 21, 2022 · 2 comments
Labels
Developer Experience Ideas about improving block and theme developer experience [Feature] Block API API that allows to express the block paradigm. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Enhancement A suggestion for improvement. [Type] New API New API to be used by plugin developers or package users.

Comments

@fabiankaegy
Copy link
Member

What problem does this address?

Gutenberg currently allows you to mark a block so that it can only be allowed once per page. Which is very useful. However there are instances where you may want to allow a block to be used multiple times within the page but only once within a certain section.

If you for example have a "Navigation" block that it would be nice to only allow the "Login" button once per navigation. But still allow multiple navigation blocks per page.

What is your proposed solution?

I'm not sure what the best API for it would be. But somehow allowing a block to only be used once within a certain context that is different to the entire page.

@fabiankaegy fabiankaegy added the [Feature] Block API API that allows to express the block paradigm. label Feb 21, 2022
@fabiankaegy fabiankaegy added [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] New API New API to be used by plugin developers or package users. Developer Experience Ideas about improving block and theme developer experience [Type] Enhancement A suggestion for improvement. labels Jul 20, 2022
@fabiankaegy fabiankaegy mentioned this issue Jul 20, 2022
58 tasks
@luisherranz
Copy link
Member

Initially, this looks to me like a subcase of #42342 where the maximum number of blocks of a certain type is 1, instead of X.

@fabiankaegy: do you see different requirements?

@fabiankaegy
Copy link
Member Author

@luisherranz i had not thought of it from top down. Instead I always looked at it bottom up which brought me to think of it similar to the supports.multiple that already exists.

I think the main need here is that as a developer I may want to say that the post author block for example should only be able to be inserted one time as an ancestor of my post template block.

(Just taking them as examples)

So it is a littel different to the need for a fixed set of inner blocks because the once per container feature should not just take the direkt child but any ancestor into account.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Developer Experience Ideas about improving block and theme developer experience [Feature] Block API API that allows to express the block paradigm. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Enhancement A suggestion for improvement. [Type] New API New API to be used by plugin developers or package users.
2 participants