Skip to content

allowedBlocks does not prevent any block from being inserted via the “Enter” key or sibling inserter #6569

Closed

Description

Issue Overview

The allowedBlocks attribute of <InnerBlocks /> is intended to only allow certain blocks to be inserted into a block. However, by pressing Enter or by using the sibling inserter(fixed by #7226), you can still insert the default block: the Paragraph block.

Steps to Reproduce (for bugs)

  1. Create a block type containing <div><InnerBlocks allowedBlocks={ [ 'core/list' ] } /></div> in its editor markup and <div><InnerBlocks.Content /></div> in its saved markup. This block should allow only allow List blocks to be inserted into it as children.
  2. Insert the block into a post.
  3. Insert multiple List blocks into the container block.
  4. Try using the sibling inserter or Enter to insert a Paragraph block.
  5. Notice that, although the Paragraph block is not shown in the inserter pop-up, it can still be inserted.

Expected Behavior

A block that sets allowedBlocks in its <InnerBlocks /> component should only allow the blocks listed in allowedBlocks to be inserted into it. Of course, the question of how to still use slash commands and/or the sibling inserter arise, as both involve inserting Paragraph blocks.

Current Behavior

Using Enter or the in-between inserter, you can insert any block into a block with an <InnerBlocks /> component.

Related Issues and/or PRs

Update: 2018-07-13

Updated this issue to no longer cover the slash command bug, which was already covered by #6070 and was fixed by #6067.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    [Feature] InserterThe main way to insert blocks using the + button in the editing interface[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions