Skip to content

Commit

Permalink
Remove actions from SidebarNavigationScreenWrapper (#48935)
Browse files Browse the repository at this point in the history
  • Loading branch information
richtabor authored Mar 8, 2023
1 parent 628663c commit 0b8f0d9
Showing 1 changed file with 3 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { __ } from '@wordpress/i18n';
import { useCallback, useMemo } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
import { store as coreStore } from '@wordpress/core-data';
import {
BlockEditorProvider,
privateApis as blockEditorPrivateApis,
} from '@wordpress/block-editor';
import { BlockEditorProvider } from '@wordpress/block-editor';
import { createBlock } from '@wordpress/blocks';

/**
Expand All @@ -17,7 +14,6 @@ import { createBlock } from '@wordpress/blocks';
import SidebarNavigationScreen from '../sidebar-navigation-screen';
import { useHistory } from '../routes';
import NavigationMenuContent from './navigation-menu-content';
import SidebarButton from '../sidebar-button';
import { NavigationMenuLoader } from './loader';
import { unlock } from '../../private-apis';
import { store as editSiteStore } from '../../store';
Expand All @@ -43,11 +39,6 @@ function SidebarNavigationScreenWrapper( { children, actions } ) {
);
}

const prioritizedInserterBlocks = [
'core/navigation-link/page',
'core/navigation-link',
];

export default function SidebarNavigationScreenNavigationMenus() {
const history = useHistory();
const { navigationMenus, hasResolvedNavigationMenus, storedSettings } =
Expand Down Expand Up @@ -104,18 +95,6 @@ export default function SidebarNavigationScreenNavigationMenus() {
},
[ history ]
);
const orderInitialBlockItems = useCallback( ( items ) => {
items.sort( ( { id: aName }, { id: bName } ) => {
// Sort block items according to `prioritizedInserterBlocks`.
let aIndex = prioritizedInserterBlocks.indexOf( aName );
let bIndex = prioritizedInserterBlocks.indexOf( bName );
// All other block items should come after that.
if ( aIndex < 0 ) aIndex = prioritizedInserterBlocks.length;
if ( bIndex < 0 ) bIndex = prioritizedInserterBlocks.length;
return aIndex - bIndex;
} );
return items;
}, [] );

if ( hasResolvedNavigationMenus && ! hasNavigationMenus ) {
return (
Expand All @@ -132,31 +111,15 @@ export default function SidebarNavigationScreenNavigationMenus() {
</SidebarNavigationScreenWrapper>
);
}
const { PrivateInserter } = unlock( blockEditorPrivateApis );

return (
<BlockEditorProvider
settings={ storedSettings }
value={ blocks }
onChange={ noop }
onInput={ noop }
>
<SidebarNavigationScreenWrapper
actions={
<PrivateInserter
rootClientId={ blocks[ 0 ].clientId }
position="bottom right"
isAppender
selectBlockOnInsert={ false }
shouldDirectInsert={ false }
__experimentalIsQuick
toggleProps={ {
as: SidebarButton,
label: __( 'Add menu item' ),
} }
orderInitialBlockItems={ orderInitialBlockItems }
/>
}
>
<SidebarNavigationScreenWrapper>
<div className="edit-site-sidebar-navigation-screen-navigation-menus__content">
<NavigationMenuContent
rootClientId={ blocks[ 0 ].clientId }
Expand Down

0 comments on commit 0b8f0d9

Please sign in to comment.