Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
talldan opened this issue Nov 6, 2019 · 3 comments
Labels
[Feature] List View Menu item in the top toolbar to select blocks from a list of links. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Bug An existing feature does not function as intended

Comments

@talldan
Copy link
Contributor

talldan commented Nov 6, 2019

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.

@talldan talldan added [Feature] List View Menu item in the top toolbar to select blocks from a list of links. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Bug An existing feature does not function as intended labels Nov 6, 2019
@jorgefilipecosta
Copy link
Member

Hi @talldan, maybe the way to address the issue is that we should never render an insert for an InnerBlocks are while the InnerBlock settings are not yet known? E.g: the inserter for the navigation should not render while InnerBlocks itself is not being rendered.

@draganescu
Copy link
Contributor

Just posting for history sake: in the navigation block this was "solved" by not rendering innerBlocks conditionally anymore. This issue is about fixing the behaviour of the appender in the navigator and also an open question if conditionally rendering InnerBlocks is a good idea in the 1st place.

@talldan talldan changed the title Block Navigator appender doesn't respect allowedBlocks when InnerBlocks is conditionally rendered. List View / Off Canvas appender doesn't respect allowedBlocks when InnerBlocks isn't rendered Mar 9, 2023
@talldan
Copy link
Contributor Author

talldan commented Jul 24, 2024

Closing this fairly old issue. While it's still could be a problem, it seems fairly stale and there haven't been any further mentions of it.

Some day, allowing allowedBlocks, template, templateLock to be specified in the block metadata would solve the problem.

@talldan talldan closed this as not planned Won't fix, can't repro, duplicate, stale Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] List View Menu item in the top toolbar to select blocks from a list of links. [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants