Skip to content

Commit

Permalink
Filters hidden blocks to only count those which are still registered (#…
Browse files Browse the repository at this point in the history
…41454)

* filters hidden blocks to only count those which are still registered

* adds a comment for filtering hidden blocks
  • Loading branch information
draganescu authored Jun 11, 2022
1 parent ebb5d82 commit 3527348
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/edit-post/src/components/block-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,23 @@ export default withSelect( ( select ) => {
isMatchingSearchTerm,
} = select( blocksStore );
const { getHiddenBlockTypes } = select( editPostStore );
const hiddenBlockTypes = getHiddenBlockTypes();

// Some hidden blocks become unregistered
// by removing for instance the plugin that registered them, yet
// they're still remain as hidden by the user's action.
// We consider "hidden", blocks which were hidden and
// are still registered.
const blockTypes = getBlockTypes();
const hiddenBlockTypes = getHiddenBlockTypes().filter( ( hiddenBlock ) => {
return blockTypes.some(
( registeredBlock ) => registeredBlock.name === hiddenBlock
);
} );
const numberOfHiddenBlocks =
Array.isArray( hiddenBlockTypes ) && hiddenBlockTypes.length;

return {
blockTypes: getBlockTypes(),
blockTypes,
categories: getCategories(),
hasBlockSupport,
isMatchingSearchTerm,
Expand Down

0 comments on commit 3527348

Please sign in to comment.