Skip to content

Commit

Permalink
Navigation block: return undefined from useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Oct 24, 2022
1 parent 7e59093 commit 272a87b
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions packages/block-library/src/navigation/edit/index.js
Expand Up @@ -272,7 +272,7 @@ function Navigation( {
fallbackNavigationMenus?.length > 0 ||
classicMenus?.length !== 1
) {
return false;
return;
}

// If there's non fallback navigation menus and
Expand Down Expand Up @@ -481,24 +481,22 @@ function Navigation( {

// Prompt the user to publish the menu they have set as a draft
const isDraftNavigationMenu = navigationMenu?.status === 'draft';
useEffect( async () => {
useEffect( () => {
hideMenuAutoPublishDraftNotice();
if ( ! isDraftNavigationMenu ) return;
try {
await editEntityRecord(
'postType',
'wp_navigation',
navigationMenu?.id,
{
status: 'publish',
},
{ throwOnError: true }
);
} catch {
if ( ! isDraftNavigationMenu ) {
return;
}
editEntityRecord(
'postType',
'wp_navigation',
navigationMenu?.id,
{ status: 'publish' },
{ throwOnError: true }
).catch( () => {
showMenuAutoPublishDraftNotice(
__( 'Error occurred while publishing the navigation menu.' )
);
}
} );
}, [ isDraftNavigationMenu, navigationMenu ] );

const stylingInspectorControls = (
Expand Down

0 comments on commit 272a87b

Please sign in to comment.