Skip to content

Commit

Permalink
Ensure fallback title by waiting on default title generation
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Mar 7, 2022
1 parent fa49a48 commit 6985531
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ function Navigation( {
isResolvingCanUserCreateNavigationMenu
}
onFinish={ handleSelectNavigation }
onCreateEmpty={ () => createNavigationMenu( [] ) }
onCreateEmpty={ () => createNavigationMenu( '', [] ) }
/>
</TagName>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 6985531

Please sign in to comment.