Skip to content

Commit

Permalink
Simplify fallbacks compute function
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Nov 9, 2022
1 parent 98da28c commit b0aecfa
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packages/block-library/src/navigation/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,17 @@ function Navigation( {
classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING;

// Only autofallback to published menus.
const fallbackNavigationMenus = useMemo( () => {
return navigationMenus
?.filter( ( menu ) => menu.status === 'publish' )
?.sort( ( menuA, menuB ) => {
const menuADate = new Date( menuA.date );
const menuBDate = new Date( menuB.date );
return menuADate.getTime() < menuBDate.getTime();
} );
}, [ navigationMenus ] );
const fallbackNavigationMenus = useMemo(
() =>
navigationMenus
?.filter( ( menu ) => menu.status === 'publish' )
?.sort( ( menuA, menuB ) => {
const menuADate = new Date( menuA.date );
const menuBDate = new Date( menuB.date );
return menuADate.getTime() < menuBDate.getTime();
} ),
[ navigationMenus ]
);

// Attempt to retrieve and prioritize any existing navigation menu unless:
// - the are uncontrolled inner blocks already present in the block.
Expand Down

0 comments on commit b0aecfa

Please sign in to comment.