-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
allowedBlocks does not prevent any block from being inserted via the “Enter” key or sibling inserter #6569
Comments
The PR #6067 made the slash command respect allowed blocks. |
@jorgefilipecosta Yeah, I created #6834, which suggests removing the placeholders from |
Furthermore, I believe if you have Might be unrelated, but is there a way to create a block that can not be inserted anywhere, but only when specifically mentioned in The use case for example would be to make a In this case the |
@ktmn I think the "parent" attribute is what you need. See here in the core column block: https://github.com/WordPress/gutenberg/blob/master/core-blocks/columns/column.js#L18 |
@chrisvanpatten thanks, Only problem that remains is that when adding a new item it opens a block selector even though only 1 possible option is available and it could just insert that block straight away And if you click the area on the left of the Should I make a separate issue of this? |
…t the default block (#7226) Fixes part of #6569. Part of a general polishing to get #6993. Insertion point was violating the allowedBlocks restriction of the parent block. The insertion point always inserts the default block and it may not be possible to insert the default block. This PR makes sure insertion point only appears if it is possible to insert the default block.
#7226 has partially fixed another part of this. The default placeholder block no longer appears in nested contexts where the default block (the Paragraph block) is not allowed, and neither does the sibling inserter. Personally, I think the sibling inserter should just open up in the insertion pop-up directly. See #6834 and #7763. But anyway, that leaves one way left of inserting the wrong block that is described in this issue: pressing Enter. If you have a block that only allows something like Heading or List blocks and you press Enter in them, you can create Paragraph blocks even though that should not be allowed. There is also the issue of being able to move blocks into a context where they are not allowed (which was not mentioned by this issue), but that should be fixed by #7212. Another issue is that you can transform a block that is allowed in the parent block to another block that is not allowed in the parent block. This is covered by #6363 and should be fixed by #7184. |
Closing in order to consolidate to #8589 which is a task that should help resolve this issue and other similar cases. |
Issue Overview
The
allowedBlocks
attribute of<InnerBlocks />
is intended to only allow certain blocks to be inserted into a block. However, by pressing Enteror by using the sibling inserter(fixed by #7226), you can still insert the default block: the Paragraph block.Steps to Reproduce (for bugs)
<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.the sibling inserter orEnter to insert a Paragraph block.Expected Behavior
A block that sets
allowedBlocks
in its<InnerBlocks />
component should only allow the blocks listed inallowedBlocks
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.
The text was updated successfully, but these errors were encountered: