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

Blocks should only be able to be transformed into other allowed blocks. #6363

Closed
jasonbahl opened this Issue Apr 23, 2018 · 2 comments

Comments

Projects
None yet
5 participants
@jasonbahl
Copy link

jasonbahl commented Apr 23, 2018

Issue Overview

If you define a list of "allowed_blocks" via this filter: https://github.com/WordPress/gutenberg/blob/a1055928b76718dc363be410ad6b2f00ff367c2c/docs/extensibility/extending-blocks.md#hiding-blocks-from-the-inserter

The blocks are filtered out of the inserter, but the "Transform Into" option allows you to transform into any block still.

I think the expectation would be for the transform into option to also respect just the allowed blocks.

Steps to Reproduce (for bugs)

  1. Use the filter allowed_block_types to just filter support for a single block type:
add_filter( 'allowed_block_types', function( $allowed_block_types, $post ) {
	return [ 'core/paragraph' ];
}, 10, 2 );
  1. Add a paragraph block
  2. Click "More Options" on the block
  3. See other "non-allowed" blocks you can transform into

Expected Behavior

  1. Use the filter allowed_block_types to just filter support for a single block type:
add_filter( 'allowed_block_types', function( $allowed_block_types, $post ) {
	return [ 'core/paragraph' ];
}, 10, 2 );
  1. Add a paragraph block
  2. Click "More Options" on the block
  3. Only see blocks that are "allowed", if any

Todos

  • Tests
  • Documentation

@gziolo gziolo added the Blocks label Apr 24, 2018

@gziolo gziolo referenced this issue Apr 24, 2018

Merged

Add shared blocks to the blocks autocompleter #6067

1 of 3 tasks complete
@jasonbahl

This comment has been minimized.

Copy link
Author

jasonbahl commented Apr 25, 2018

Any chance this existing PR (#4097) already addresses this? Seems semi-related.

@noisysocks

This comment has been minimized.

Copy link
Member

noisysocks commented May 16, 2018

canInsertBlockType( state, blockType, parentUID ) which is in #6753 could be useful for addressing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.