gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Validate or handle undefined block category

Open aduth opened this issue 9 years ago • 4 comments

Related: #2263

Issue Overview

If a block has not assigned a category property, it is not possible to insert.

Steps to Reproduce (for bugs)

  1. Navigate to Gutenberg > New Post
  2. 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: () => '' } );
  3. Toggle one of the inserters
  4. 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'?)

aduth avatar Aug 07 '17 14:08 aduth

I've added a few validation checks and updated accordingly all the test units.

kuoko avatar Aug 09 '17 15:08 kuoko

How do I register a custom block category? Can't find docs on that

zackify avatar Apr 23 '18 23:04 zackify

@zackify This is not yet possible, though is currently being proposed / discussed at #1732.

aduth avatar Apr 24 '18 02:04 aduth

@aduth thanks!!

zackify avatar Apr 24 '18 02:04 zackify