Skip to content

Autocompleter (slash command) doesn't respect allowed_block_types #6070

Description

@noisysocks

Issue Overview

The blocks autocompleter (what you get when you type a /) doesn't respect the allowed_block_types filter.

Steps to Reproduce (for bugs)

  1. Add the following to the top of lib/load.php:
add_filter( 'allowed_block_types', function() {
	return [ 'core/paragraph', 'core/image', 'core/quote' ];
} );
  1. Create a post
  2. Press /

Expected Behavior

Only the Paragraph, Image and Quote bugs should appear in the dropdown.

Shared blocks should be properly filtered when using allowed_block_types filter.

Current Behavior

All blocks should appear in the dropdown.

If you limit the blocks which can be shown using the allowed_block_types filter then shared blocks do not appear in the 'Shared' block inserter tab.

Possible Solution

The getInserterItems selector will correctly filter out non-allowed blocks if you pass the editor setting as its second argument.

Screenshots / Video

autocompleter bug

Related Issues and/or PRs

#4225 #3791 — both of these would also be fixed by the above suggested solution.

Activity

  1. added
    [Type] BugAn existing feature does not function as intended
    [Feature] InserterThe main way to insert blocks using the + button in the editing interface
    on Apr 9, 2018
  2. added this to the milestone on Apr 9, 2018
  3. paulwilde commented on Apr 9, 2018

    @paulwilde
    Contributor

    #5893 is also related. Probably a dupe actually.

  4. noisysocks commented on Apr 10, 2018

    @noisysocks
    MemberAuthor

    I don't think it's a dupe. #5893 is referring to shared blocks not appearing in the inserter when allowed_block_types is set to false, whereas #6070 is referring to all blocks mistakenly appearing in the / command regardless of what allowed_block_types is set to.

  5. jasonbahl commented on Apr 27, 2018

    @jasonbahl

    #6363 seems related.

  6. noisysocks commented on Jun 6, 2018

    @noisysocks
    MemberAuthor

    #6067 fixed this.

    screen shot 2018-06-06 at 16 02 02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] InserterThe main way to insert blocks using the + button in the editing interface[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions