Validate or handle undefined block category
Related: #2263
Issue Overview
If a block has not assigned a category property, it is not possible to insert.
Steps to Reproduce (for bugs)
- Navigate to Gutenberg > New Post
- Insert the following snippet in your browser Developer Tools console to register the problematic block type
wp.blocks.registerBlockType( 'core/demo', { title: 'demo', edit: () => '', save: () => '' } );
- Toggle one of the inserters
- Insert demo block
Expected Behavior
One can search for or manually find the demo block.
This, or I receive an error in the console when block category is not assigned.
Current Behavior
It is not possible to find nor insert the demo block.
Possible Solution
Block registration already includes a number of validation checks. We could augment with another check to verify that the title is usable:
https://github.com/WordPress/gutenberg/blob/e5130c3/blocks/api/registration.js#L39-L79
Alternatively, we could allow the block to be registered and assign it to a default category ('common'?)
I've added a few validation checks and updated accordingly all the test units.
How do I register a custom block category? Can't find docs on that
@zackify This is not yet possible, though is currently being proposed / discussed at #1732.
@aduth thanks!!