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
2 tasks
jasonbahl opened this issue Apr 23, 2018 · 2 comments
Closed
2 tasks
Assignees
Labels
[Feature] Blocks Overall functionality of blocks [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@jasonbahl
Copy link

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
@youknowriad youknowriad added the [Type] Bug An existing feature does not function as intended label Apr 23, 2018
@gziolo gziolo added the [Feature] Blocks Overall functionality of blocks label Apr 24, 2018
@jasonbahl
Copy link
Author

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

@noisysocks
Copy link
Member

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
Labels
[Feature] Blocks Overall functionality of blocks [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants