Skip to content

Commit

Permalink
[Inserter]: Don't show empty reusable tab if not allowed to insert …
Browse files Browse the repository at this point in the history
…reusable blocks (#46922)
  • Loading branch information
ntsekouras authored Jan 6, 2023
1 parent eac04cd commit 5cf556a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions packages/block-editor/src/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,24 @@ function InserterMenu(
insertionIndex: __experimentalInsertionIndex,
shouldFocusBlock,
} );
const { showPatterns, hasReusableBlocks } = useSelect(
const { showPatterns, inserterItems } = useSelect(
( select ) => {
const { __experimentalGetAllowedPatterns, getSettings } =
const { __experimentalGetAllowedPatterns, getInserterItems } =
select( blockEditorStore );
return {
showPatterns: !! __experimentalGetAllowedPatterns(
destinationRootClientId
).length,
hasReusableBlocks:
!! getSettings().__experimentalReusableBlocks?.length,
inserterItems: getInserterItems( destinationRootClientId ),
};
},
[ destinationRootClientId ]
);
const hasReusableBlocks = useMemo( () => {
return inserterItems.some(
( { category } ) => category === 'reusable'
);
}, [ inserterItems ] );

const mediaCategories = useMediaCategories( destinationRootClientId );
const showMedia = !! mediaCategories.length;
Expand Down

1 comment on commit 5cf556a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 5cf556a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3854531847
📝 Reported issues:

Please sign in to comment.