Skip to content

Commit

Permalink
Fix navigation block console error (#44594)
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan authored Sep 30, 2022
1 parent 469e288 commit 9ae5785
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,18 @@ function Navigation( {
hasResolvedNavigationMenus &&
! hasUncontrolledInnerBlocks;

if ( isPlaceholder && ! ref ) {
/**
* this fallback only displays (both in editor and on front)
* the list of pages block if no menu is available as a fallback.
* We don't want the fallback to request a save,
* nor to be undoable, hence we mark it non persistent.
*/
__unstableMarkNextChangeAsNotPersistent();
replaceInnerBlocks( clientId, [ createBlock( 'core/page-list' ) ] );
}
useEffect( () => {
if ( isPlaceholder && ! ref ) {
/**
* this fallback only displays (both in editor and on front)
* the list of pages block if no menu is available as a fallback.
* We don't want the fallback to request a save,
* nor to be undoable, hence we mark it non persistent.
*/
__unstableMarkNextChangeAsNotPersistent();
replaceInnerBlocks( clientId, [ createBlock( 'core/page-list' ) ] );
}
}, [ clientId, isPlaceholder, ref ] );

const isEntityAvailable =
! isNavigationMenuMissing && isNavigationMenuResolved;
Expand Down

0 comments on commit 9ae5785

Please sign in to comment.