Skip to content

Add ability to limit the number of items within an Inner Blocks area #42342

@fabiankaegy

Description

@fabiankaegy

What problem does this address?

Part of #41236.

When you have a custom tabs block for example you can build that to work similar to the core columns block. You have one wrapping block that contains individual tab item or column blocks that intern allow editors to place other blocks inside of them. The issue however is that you may want to restrict the ability of editors to add more than 5 tabs which currently isn't possible.
Tabs are just an example here. This applies to all kinds of blocks that follow the parent/child block relationship. Even the Core Columns block doesn't really support more than 6 columns. But editors can still select an individual column block and duplicate it.

As a workaround, you can define a custom renderAppender function for the area of the inner block and only render the custom block appended whenever there are fewer than the max number of items in the area of the inner block. But that still doesn't solve the root issue because editors can still duplicate a block to create more than should be possible.

What is your proposed solution?

Add a new optional prop to the InnerBlocks props that allows developers to set a max number of items. It could also be achieved by introducing a new level of templateLock which would prevent adding more items whilst still not locking down any of the already existing items.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] Block APIAPI that allows to express the block paradigm.[Feature] Nested / Inner BlocksAnything related to the experience of nested/inner blocks inside a larger container, like Group or P[Type] EnhancementA suggestion for improvement.[Type] New APINew API to be used by plugin developers or package users.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions