WordPress/gutenberg

Block directory doesn't work when blocks are hidden

ryelle opened this issue · 2 comments

Description

If you have any blocks hidden, the block directory won't load any external results. This is caused by the canInsertBlockType check, which checks against allowedBlockTypes. When there are hidden blocks, this list is set to the current registered blocks, minus those hidden blocks (source).

Since this is a safelist to match against, rather than a "disallowed" list, anything not on the list is blocked, and since it's created from locally registered blocks, nothing in the Block Directory is allowed.

Related to #33954

Step-by-step reproduction instructions

  1. Open an editor, go to Preferences > Blocks
  2. Uncheck some blocks
  3. Go back to the block inserter, try searching for a block in the directory — table, recipe, etc
  4. No results will load
  5. Unhide the blocks
  6. Try the search again, it should work

Screenshots, screen recording, code snippet

Screen.Recording.2022-02-03.at.12.49.18.PM.mov

Environment info

  • WP 6.0-alpha
  • Gutenberg trunk 7ab78a2
  • Theme: emptytheme
  • No other plugins

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

Since this is a safelist to match against, rather than a "disallowed" list, anything not on the list is blocked, and since it's created from locally registered blocks, nothing in the Block Directory is allowed.

It looks like we finally need to implement a disallowedBlockTypes as an addition to allowedBlockTypes to resolve the issue reported in this issue. More importantly, it would give more flexibility over controlling blocks in different contexts.

Can confirm this is still present in WP6.3