Skip to content

Commit

Permalink
Add empty message in case of empty menu
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Mar 28, 2022
1 parent 782602f commit 9a59e6e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export default function NavigationInspector() {
// Guard by only allowing their usage if there are published Nav Menus.
const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];

const hasInnerBlocks = !! publishedInnerBlocks?.length;

useEffect( () => {
if ( isResolvingNavigationMenus ) {
speak( 'Loading Navigation sidebar menus.' );
Expand Down Expand Up @@ -199,7 +201,7 @@ export default function NavigationInspector() {
<div className="edit-site-navigation-inspector__placeholder is-child" />
</>
) }
{ ! isLoading && (
{ hasInnerBlocks && ! isLoading && (
<BlockEditorProvider
value={ publishedInnerBlocks }
onChange={ onChange }
Expand All @@ -211,6 +213,12 @@ export default function NavigationInspector() {
/>
</BlockEditorProvider>
) }

{ ! hasInnerBlocks && ! isLoading && (
<p className="edit-site-navigation-inspector__empty-msg">
{ __( 'Navigation Menu is empty.' ) }
</p>
) }
</div>
);
}

0 comments on commit 9a59e6e

Please sign in to comment.