How to exclude parent block from group/ columns innerBlocks?

383 Views Asked by At

I have created a custom block and used Gutenberg component as inner/child blocks. It is working fine and t's not showing in it's inner blocks list but it is shown if I try to add inside a group/columns block. Is there a way to remove it?

Image 1: Parent not shown directly inside the block Parent not shown directly inside the block

Image 2: Parent getting shown inside the group block created under parent block. Parent getting shown inside the group block created under parent block

1

There are 1 best solutions below

0
On

When the child block is registered, define its parent block which will restrict where the block can be inserted, eg:

registerBlockType('myproject/child-block', {
    ...
    parent: ['myproject/parent-block']
}

To take this a step further, you could create a main custom block that all your other blocks define as their parent thus disabling them from being added via group.