Skip to content

Commit

Permalink
Update: Make OffCanvasEditor use LeafMoreMenu by default. (#47844)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta authored Feb 9, 2023
1 parent 44e6ff6 commit c7dd533
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@ import { createBlock } from '@wordpress/blocks';
import { addSubmenu, moreVertical } from '@wordpress/icons';
import { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';
import { useDispatch } from '@wordpress/data';
import { store as blockEditorStore, BlockTitle } from '@wordpress/block-editor';
import { __, sprintf } from '@wordpress/i18n';

/**
* Internal dependencies
*/
import { store as blockEditorStore } from '../../store';
import BlockTitle from '../block-title';

const POPOVER_PROPS = {
className: 'block-editor-block-settings-menu__popover',
position: 'bottom right',
variant: 'toolbar',
};

export const LeafMoreMenu = ( props ) => {
export default function LeafMoreMenu( props ) {
const { clientId, block } = props;

const { insertBlock, replaceBlock, removeBlocks, replaceInnerBlocks } =
Expand Down Expand Up @@ -90,4 +95,4 @@ export const LeafMoreMenu = ( props ) => {
) }
</DropdownMenu>
);
};
}
2 changes: 2 additions & 0 deletions packages/block-editor/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as globalStyles from './components/global-styles';
import { ExperimentalBlockEditorProvider } from './components/provider';
import { lock } from './lock-unlock';
import OffCanvasEditor from './components/off-canvas-editor';
import LeafMoreMenu from './components/off-canvas-editor/leaf-more-menu';

/**
* Experimental @wordpress/block-editor APIs.
Expand All @@ -13,5 +14,6 @@ export const experiments = {};
lock( experiments, {
...globalStyles,
ExperimentalBlockEditorProvider,
LeafMoreMenu,
OffCanvasEditor,
} );
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { __, sprintf } from '@wordpress/i18n';
* Internal dependencies
*/
import NavigationMenuSelector from './navigation-menu-selector';
import { LeafMoreMenu } from '../leaf-more-menu';
import { unlock } from '../../private-apis';
import DeletedNavigationWarning from './deleted-navigation-warning';
import useNavigationMenu from '../use-navigation-menu';
Expand All @@ -34,7 +33,7 @@ const MainContent = ( {
isNavigationMenuMissing,
onCreateNew,
} ) => {
const { OffCanvasEditor } = unlock( blockEditorExperiments );
const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorExperiments );
// Provide a hierarchy of clientIds for the given Navigation block (clientId).
// This is required else the list view will display the entire block tree.
const clientIdsTree = useSelect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const ALLOWED_BLOCKS = {
export default function NavigationMenu( { innerBlocks, onSelect } ) {
const { updateBlockListSettings } = useDispatch( blockEditorStore );

const { OffCanvasEditor } = unlock( blockEditorExperiments );
const { OffCanvasEditor, LeafMoreMenu } = unlock( blockEditorExperiments );

//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
//Think through a better way of doing this, possible with adding allowed blocks to block library metadata
Expand All @@ -56,5 +56,11 @@ export default function NavigationMenu( { innerBlocks, onSelect } ) {
} );
}, [ updateBlockListSettings, innerBlocks ] );

return <OffCanvasEditor blocks={ innerBlocks } onSelect={ onSelect } />;
return (
<OffCanvasEditor
blocks={ innerBlocks }
onSelect={ onSelect }
LeafMoreMenu={ LeafMoreMenu }
/>
);
}

1 comment on commit c7dd533

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in c7dd533.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4137558918
📝 Reported issues:

Please sign in to comment.