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

commented Apr 17, 2019

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 force-pushed the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch from b271e2d to 935800d May 28, 2019

@draganescu
Copy link
Contributor

left a comment

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 Aug 5, 2019

@jorgefilipecosta jorgefilipecosta merged commit e0d2f4e into master Aug 5, 2019

1 of 4 checks passed

Filter opened Filter opened
Details
Filter opened Filter opened
Details
Milestone It Milestone It
Details
Travis CI - Pull Request Build Passed
Details

@jorgefilipecosta jorgefilipecosta deleted the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch Aug 5, 2019

@jorgefilipecosta jorgefilipecosta restored the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch Aug 5, 2019

@jorgefilipecosta jorgefilipecosta deleted the fix/ainsert-before-and-after-appear-even-when-defaultblock-can-not-be-inserter branch Aug 5, 2019

@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
You can’t perform that action at this time.