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

"Insert Before/After" menu options disappear if paragraph block is hidden from inserter #46753

Open
cbirdsong opened this issue Dec 22, 2022 · 6 comments
Labels
[Block] Paragraph Affects the Paragraph Block [Feature] Inserter The main way to insert blocks using the + button in the editing interface [Type] Enhancement A suggestion for improvement.

Comments

@cbirdsong
Copy link

cbirdsong commented Dec 22, 2022

Description

The "Insert Before/After" items in the block options menu disappear when the paragraph block is disabled.

Step-by-step reproduction instructions

  1. Click on the three vertical dots menu in the top right.
  2. Click "Preferences"
  3. Click "Blocks"
  4. Uncheck "Paragraph"

or

  1. Register a Javascript file that runs in the editor.
  2. Inside it, use hideBlockTypes to hide the paragraph block.

Screenshots, screen recording, code snippet

via the UI:

CleanShot.2022-12-22.at.13.37.50.mp4

via Javascript run in the editor:

wp.data.dispatch("core/edit-post").hideBlockTypes(["core/paragraph"]);

Environment info

WordPress version 6.1.1. The Gutenberg plugin is not active.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes


This issue is discussed in #23603 in the context of inner blocks, but this problem much wider in scope.

@t-hamano
Copy link
Contributor

t-hamano commented Dec 23, 2022

@cbirdsong

Thank you for submitting the issue.

I believe this is the intended behavior. By #15021, the insert button is intentionally hidden if the default block (i.e. paragraph block) cannot be inserted.

edit: I missed #23603 which you noted at the end. It may need improvement as described in this issue.

@t-hamano t-hamano added [Feature] Inserter The main way to insert blocks using the + button in the editing interface [Block] Paragraph Affects the Paragraph Block labels Dec 23, 2022
@cbirdsong
Copy link
Author

cbirdsong commented Dec 23, 2022

This is very unintuitive behavior, especially considering it occurs when the paragraph block has only been hidden, not removed entirely.

@ntsekouras
Copy link
Contributor

Hm.. I don't think we can make arbitrary decisions about setting a new default block, but maybe we would need a way to set the default block from the UI? 🤔

@cbirdsong
Copy link
Author

It seems like the most sensible solution would be a new default block whose only job is to show the inserter and the "type / to choose a block" prompt, perhaps conditionally based on if it's a restricted inner blocks container like the buttons block.

By default it could allow typing anything prefixed with a /, and if the paragraph block is registered it could also allow content that isn't prefixed by /, which would transform it into a paragraph block once that happens?

@cooperfellows
Copy link

Love the idea of an "inserter block" that can be utilized in these instances, like how @gwwar outlines in the second approach outlined in #23603 (comment).

Our use case is that we have disabled the default paragraph block at the highest level, and only allow it as an innerBlock in some custom Gutenberg blocks that we have developed.

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Jul 27, 2023
@rleecrewmp
Copy link

Hm.. I don't think we can make arbitrary decisions about setting a new default block, but maybe we would need a way to set the default block from the UI? 🤔

Is there a reason we can't have it just open the block picker if there is no default block available?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Paragraph Affects the Paragraph Block [Feature] Inserter The main way to insert blocks using the + button in the editing interface [Type] Enhancement A suggestion for improvement.
6 participants