0

I have the parent block example/parent that contains

<InnerBlocks
  allowedBlocks={['example/children']}
  template={template}
/>

And the child block example/children with

registerBlockType('example/children', {
  apiVersion: 2,
  ...

  parent: ['example/parent'],

All works as expected, but if I create reusable block from a children, it can not be inserted in any other parent again, the [+] icon will automatically create new block without the option to choose a reusable block. Is there a way to enable allowedBlocks example/children or reusable block of type example/children ?

Edit (more details)

I have the case of parent - children blocks, and inside the parent block InnerBlocks should be allowed both the children block and reusable blocks (preferable created from the example/children)

2
  • reusable blocks are blocks of type core/block, the post technically isn't aware of sub-blocks as the contents of a core/block belong to another post. I had to re-readd your last paragraph several times though and I'm still unsure what it's trying to put across, but I'm guessiing that you'r asking why you can't insert a reusable block inside your custom block when you've used alllowedBlocks? Or have I miisunderstood? Can you edit the question to explain in a different clearer way that's less ambiguous?
    – Tom J Nowell
    Oct 5, 2021 at 8:59
  • Yes, "why you can't insert a reusable block inside your custom block when you've used alllowedBlocks?" This is what I am trying to get Oct 7, 2021 at 7:21

1 Answer 1

0

Yes, "why you can't insert a reusable block inside your custom block when you've used alllowedBlocks?" This is what I am trying to get

This is because you haven't allowed them:

allowedBlocks={['example/children']}

The list of allowed blocks does not include reusable blocks ( core/block ), so they are not allowed and cannot be inserted. Add core/block to the list to fix that.

Remember, a reusable block is a block of type core/block, its content belongs to another post entirely. If you say only example/children blocks are allowed, this does not mean a reusable block that contains example/children can be inserted, because a reusable block is of type core/block and has no inner blocks. You only see inner blocks in the editor because the UI is being helpful and showing you the blocks from the other post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.