Validate or handle undefined block title
Issue Overview
When a registered block omits its title property, the editor crashes when searching the Inserter Menu.
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', { edit: () => '', save: () => '' } );
- Toggle one of the inserters
- Start searching
Expected Behavior
Search occurs.
Current Behavior
The editor crashes.
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
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 but not appear in the inserter when searched for by testing whether the block has a title before performing toLowerCase.
I've added some additional validation to verify the block title and updated the test-unit accordingly.