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

InnerBlocks have no inserter when core/paragraph is not in allowedBlocks #7763

Closed
ktmn opened this issue Jul 7, 2018 · 8 comments
Closed
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P

Comments

@ktmn
Copy link

ktmn commented Jul 7, 2018

This happened with 3.2 when the core/paragraph is no longer rendered (which is great).

Describe the bug
<InnerBlocks> have no block inserter when core/paragraph is not in the allowedBlocks prop.

Only way I can insert more blocks is to add a template with the block I want and then duplicate it.

Do I need to render the inserter myself?

To Reproduce
Steps to reproduce the behavior:

  1. <wp.editor.InnerBlocks allowedBlocks={['custom/element']} />

There is not even the "inbetween" inserter, which usually allowed to add a block above a block, but not below for some reason.

@ktmn
Copy link
Author

ktmn commented Jul 7, 2018

Ok I've missed the fact that there is an ever-present inserter in the top left corner. And that works. I've just barely ever used it for some reason. Intuitively I figured it just inserts a new block to the bottom, but that's not the case.

Do I need to render the inserter myself?

Is it possible to do that though? Maybe an inserter with no popups, just pushes another specific block to the InnerBlocks.

@ktmn ktmn closed this as completed Jul 7, 2018
@ktmn
Copy link
Author

ktmn commented Jul 7, 2018

I'm reopening this cause it didn't pan out.

The top left corner block inserter button only works when the InnerBlocks (or one of it's child blocks) is active, but if the InnerBlocks doesn't have a template, then it's impossible to make it active in order to insert a block into it.

Having a template was perfect, because the InnerBlocks would already contain the item that is most likely wanted there, how ever upon refreshing the editor all the additional blocks that were not specified in the template prop are deleted.

<wp.editor.InnerBlocks
	allowedBlocks={['custom/block']}
	template={[
		['custom/block', {}],
	]}
	templateLock={false}
/>

So the above code is problematic when I want unlimited amount of custom/blocks in the InnerBlocks. Only the first one remains after refresh, since the template doesn't include the others.
But if I don't specify a template there is no way to insert any blocks into it.

@ktmn ktmn reopened this Jul 7, 2018
@ZebulanStanphill
Copy link
Member

Related: #6569, #6834, and #7006.

@t-wright
Copy link

So the above code is problematic when I want unlimited amount of custom/blocks in the InnerBlocks. Only the first one remains after refresh, since the template doesn't include the others.
But if I don't specify a template there is no way to insert any blocks into it.

I'm also seeing this issue in 3.2 with the exact same implementation. Even with templateLock={false} template appears to be locked and any additional custom blocks vanish after refresh and only the one specified in the template remains. Only happens in the visual editor. If you switch to the code editor and refresh the additional blocks remain.

@ZebulanStanphill
Copy link
Member

ZebulanStanphill commented Jul 16, 2018

The best way to solve this, in my opinion, is to change the sibling inserter to open the inserter menu directly.

Pros of changing the sibling inserter to open the inserter menu directly include:

  • One less click to insert a block.
  • More intuitive. You would think that the sibling inserter would just open the inserter menu directly, so why does it make you go through the step of clicking another inserter icon in the placeholder it inserts instead?
  • Improves consistency by making the sibling inserter open the same menu as the button in the top bar and the button in placeholders, rather than having the sibling inserter just insert a placeholder.
  • Does not interfere with normal post writing and keyboard users. Pressing Enter still inserts a new placeholder/Paragraph as always.
  • Allows sibling inserter to be used in nested contexts again while still preventing Paragraph blocks from being inserted in contexts where they are not allowed.

I can not think of any cons; can you?

@t-wright
Copy link

FYI - I think the issue of the vanishing blocks was fixed with pull request #7723

@mtias mtias added [Feature] Inserter The main way to insert blocks using the + button in the editing interface [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P labels Jul 19, 2018
@ZebulanStanphill
Copy link
Member

I think this issue can be closed thanks to #10136. I still maintain, however, that the sibling inserter should appear after the last block in a context, as the new non-Paragraph appender takes up space and makes the editor look less like the front-end.

@talldan
Copy link
Contributor

talldan commented Feb 19, 2019

Agreed that #10136 closes this. If I've missed any reason why it shouldn't be closed feel free to request that it's reopened.

@talldan talldan closed this as completed Feb 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Feature] Nested / Inner Blocks Anything related to the experience of nested/inner blocks inside a larger container, like Group or P
Projects
None yet
Development

No branches or pull requests

5 participants