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

Block Editor: Avoid default block insertion if no default block type #15786

Merged
merged 3 commits into from
May 23, 2019

Conversation

aduth
Copy link
Member

@aduth aduth commented May 22, 2019

Previously: #15543 (comment)
Cherry-picks 2f1a82f from #15543 (temporarily)

This pull request seeks to resolve an error which occurs when deleting the last of the blocks in a post, if there is no default block type.

Implementation Notes:

getDefaultBlockName is implemented to handle unregistrations, and thus we should be consistent to respect this nullable return type.

* @return {string?} Default block name.

case 'REMOVE_BLOCK_TYPES':
if ( action.names.indexOf( state ) !== -1 ) {
return null;
}
return state;

Testing Instructions:

Verify no error when deleting all blocks if the default block type is disabled:

  1. (Prerequisite) Remove the default block type:
    • wp.data.dispatch( 'core/blocks' ).removeBlockTypes( wp.data.select( 'core/blocks' ).getDefaultBlockName() );
  2. Add an Image block
  3. Delete the Image block
  4. Ensure no errors are shown in the console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Block editor /packages/block-editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants