From 82c3f57bfaadbc69d29c2c8ef54ceb4d97a82a95 Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 4 Mar 2022 13:56:59 +0000 Subject: [PATCH] Ensure fallback title by waiting on default title generation --- packages/block-library/src/navigation/edit/index.js | 2 +- .../src/navigation/edit/use-create-navigation-menu.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/navigation/edit/index.js b/packages/block-library/src/navigation/edit/index.js index f9a5c481057bc..fe1ded1896357 100644 --- a/packages/block-library/src/navigation/edit/index.js +++ b/packages/block-library/src/navigation/edit/index.js @@ -544,7 +544,7 @@ function Navigation( { } selectBlock( clientId ); } } - onCreateEmpty={ () => createNavigationMenu( [] ) } + onCreateEmpty={ () => createNavigationMenu( '', [] ) } /> ); diff --git a/packages/block-library/src/navigation/edit/use-create-navigation-menu.js b/packages/block-library/src/navigation/edit/use-create-navigation-menu.js index 723cc18f70c14..41a2fea97420a 100644 --- a/packages/block-library/src/navigation/edit/use-create-navigation-menu.js +++ b/packages/block-library/src/navigation/edit/use-create-navigation-menu.js @@ -27,13 +27,13 @@ export default function useCreateNavigationMenu( clientId ) { // This callback uses data from the two placeholder steps and only creates // a new navigation menu when the user completes the final step. const create = useCallback( - ( title = null, blocks = [] ) => { + async ( title = null, blocks = [] ) => { setStatus( PENDING ); setValue( null ); setError( null ); if ( ! title ) { - title = generateDefaultTitle().catch( ( err ) => { + title = await generateDefaultTitle().catch( ( err ) => { setError( err?.message ); setStatus( ERROR ); throw new Error(