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

Don't open block appender modal if only one block is allowed #19620

Closed
ghost opened this issue Jan 14, 2020 · 8 comments
Closed

Don't open block appender modal if only one block is allowed #19620

ghost opened this issue Jan 14, 2020 · 8 comments
Assignees
Labels
[Feature] Inserter The main way to insert blocks using the + button in the editing interface [Type] Bug An existing feature does not function as intended

Comments

@ghost
Copy link

ghost commented Jan 14, 2020

Hey,

I am only allowing one block on my page using this code:

add_filter('allowed_block_types', 'sp_allowed_block_types', 10, 2);

function sp_allowed_block_types($allowed_blocks, $post)
{

    if ($post->post_type === 'page' || $post->post_type === 'post') {
        $allowed_blocks = array(
            'sp/block',
        );
    }

    return $allowed_blocks;
}

It doesn't really make sense to allow the modal in this case, the appender icon should instead insert the only block that is available.

screencapture-spacepress-local-sp3-wp-admin-post-php-2020-01-14-12_24_51

@mtias
Copy link
Member

mtias commented Jan 14, 2020

This is how the "navigation" and "buttons" blocks work already. cc @jorgefilipecosta

@mtias mtias added the [Type] Question Questions about the design or development of the editor. label Jan 14, 2020
@chrisvanpatten
Copy link
Member

Looks like #16708 is where this was added. @dnnsjsk are you using Gutenberg in WordPress core or via the plugin? It doesn't look like this change made it to WP core yet.

@mtias
Copy link
Member

mtias commented Jan 14, 2020

Ah, indeed.

@ghost
Copy link
Author

ghost commented Jan 15, 2020

@chrisvanpatten I am using the Gutenberg plugin. The problem also persists when only allowing the Paragraph block.

paragraph

@jorgefilipecosta jorgefilipecosta added the [Type] Bug An existing feature does not function as intended label Jan 20, 2020
@jorgefilipecosta
Copy link
Member

I did some tests, and it seems like the behavior currently implemented to insert the block if only one block is allowed only happens for insertions inside inner blocks. Outside innerblocks for the root bock, it does not occur. This seems inconsistent, and if possible, it is something that we should fix.

@talldan talldan added [Feature] Inserter The main way to insert blocks using the + button in the editing interface and removed [Type] Question Questions about the design or development of the editor. labels Apr 23, 2020
@paaljoachim
Copy link
Contributor

Hello everyone. It would be great with a status update here.
@jorgefilipecosta is this issue something you might be able to take a closer look at?

@jorgefilipecosta
Copy link
Member

Hi @paaljoachim, yes I can take a close look into this issue :)

@jorgefilipecosta jorgefilipecosta self-assigned this May 3, 2021
@Mamaduka
Copy link
Member

I'm going to close this. The Inserter's behavior has changed recently. Now, it displays the allowed block at the top, followed by the remaining blocks. See #62169.

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 [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

6 participants