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

Fix: Insert Before and Insert After appear even when default block can't be inserted #15024

Conversation

jorgefilipecosta
Copy link
Member

Insert Before and Insert after just insert the default block. After the merge of the inserter restrictions PR if a block cannot be inserted the insert action does nothing.
We had a bug if the default block could not be inserted we still allowed the user to click Insert After and Before while the actions did nothing.

This PR does not render an insert before/after button if the default block cannot be inserted.

How has this been tested?

I disabled the default block using:


function my_plugin_allowed_block_types( $allowed_block_types, $post ) {
	if ( 'post' !== $post->post_type ) {
		return $allowed_block_types;
	}
	return array( 'core/video', 'core/image' );
}


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

I created a new post; I inserted an image; I pressed the button to open the "Elipsis menu" and verified "Insert Before/After" buttons don't appear.

I inserted the block "Allowed Blocks Set" available at https://gist.github.com/jorgefilipecosta/ee7969d72e13e9e8e3ab58efdd1fd03b.
I verified that when I open the ellipsis menu of a block inside "Allowed Blocks Set" the insert before/after buttons don't appear.

@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended [Feature] Inserter The main way to insert blocks using the + button in the editing interface labels Apr 17, 2019
@jorgefilipecosta jorgefilipecosta force-pushed the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch from b271e2d to 935800d Compare May 28, 2019 14:32
Copy link
Contributor

@draganescu draganescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good, and testing worked as described.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch from 935800d to 484272c Compare August 5, 2019 11:30
@jorgefilipecosta jorgefilipecosta merged commit e0d2f4e into master Aug 5, 2019
@jorgefilipecosta jorgefilipecosta deleted the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch August 5, 2019 13:57
@jorgefilipecosta jorgefilipecosta restored the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch August 5, 2019 13:57
@jorgefilipecosta jorgefilipecosta deleted the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch August 5, 2019 13:57
@youknowriad youknowriad added this to the Gutenberg 6.3 milestone Aug 9, 2019
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

Successfully merging this pull request may close these issues.

3 participants