Skip to content

List View / Off Canvas appender doesn't respect allowedBlocks when InnerBlocks isn't rendered #18295

@talldan

Description

@talldan

Describe the bug
Related #18100

This is a very niche issue and hard to explain, but one that might become apparent if we start using the block navigator more.

#18100 introduces a block appender in the navigator:
Screen Shot 2019-10-25 at 3 03 34 pm

The issue experienced is that If a user accesses the navigator before InnerBlocks had rendered and then clicked an appender, the user could insert any type of inner block, despite there being allowedBlocks defined on InnerBlocks.

The issue was that the InnerBlocks component had some conditional rendering:

{ ( isSelected || isParentOfSelectedBlock ) &&
<InnerBlocks
allowedBlocks={ [ 'core/navigation-menu-item' ] }
renderAppender={ hasDescendants ? InnerBlocks.ButtonBlockAppender : false }
/>
}

If for any reason the component wasn't rendered before accessing the navigator, allowedBlocks wouldn't work as registration of those allowed blocks is dependent on the component mounting.

Questionable whether this is considered a flaw or a bug in the block implementation, but it's something that can't really be policed for third party blocks and could cause some very unusual issues for users creating posts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] List ViewMenu item in the top toolbar to select blocks from a list of links.[Feature] Nested / Inner BlocksAnything related to the experience of nested/inner blocks inside a larger container, like Group or P[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions