Skip to content

Commit

Permalink
Hide the ellipsis menu behind __experimentalWithEllipsisMenu flag
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed May 19, 2020
1 parent 45b527c commit 691c486
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
import DescenderLines from './descender-lines';
import BlockNavigationBlockContents from './block-contents';
import BlockSettingsMenu from '../block-settings-menu';
import { useBlockNavigationContext } from './context';

export default function BlockNavigationBlock( {
block,
Expand All @@ -46,6 +47,9 @@ export default function BlockNavigationBlock( {
'block-editor-block-navigation-block__mover-cell',
{ 'is-visible': hasVisibleMovers }
);
const {
__experimentalWithEllipsisMenu: withEllipsisMenu,
} = useBlockNavigationContext();

return (
<BlockNavigationLeaf
Expand Down Expand Up @@ -82,7 +86,7 @@ export default function BlockNavigationBlock( {
{ ...props }
/>

{ level > 1 && (
{ withEllipsisMenu && level > 1 && (
<BlockSettingsMenu clientIds={ [ clientId ] } />
) }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createContext, useContext } from '@wordpress/element';

export const BlockNavigationContext = createContext( {
__experimentalWithBlockNavigationSlots: false,
__experimentalWithEllipsisMenu: false,
} );

export const useBlockNavigationContext = () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function BlockNavigation( {
rootBlocks,
selectedBlockClientId,
selectBlock,
__experimentalWithEllipsisMenu,
__experimentalWithBlockNavigationSlots,
} ) {
if ( ! rootBlocks || rootBlocks.length === 0 ) {
Expand All @@ -41,6 +42,9 @@ function BlockNavigation( {
blocks={ [ rootBlock ] }
selectedBlockClientId={ selectedBlockClientId }
selectBlock={ selectBlock }
__experimentalWithEllipsisMenu={
__experimentalWithEllipsisMenu
}
__experimentalWithBlockNavigationSlots={
__experimentalWithBlockNavigationSlots
}
Expand All @@ -52,6 +56,9 @@ function BlockNavigation( {
blocks={ rootBlocks }
selectedBlockClientId={ selectedBlockClientId }
selectBlock={ selectBlock }
__experimentalWithEllipsisMenu={
__experimentalWithEllipsisMenu
}
__experimentalWithBlockNavigationSlots={
__experimentalWithBlockNavigationSlots
}
Expand Down
11 changes: 9 additions & 2 deletions packages/block-editor/src/components/block-navigation/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ import { BlockNavigationContext } from './context';
*/
export default function BlockNavigationTree( {
__experimentalWithBlockNavigationSlots,
__experimentalWithEllipsisMenu,
...props
} ) {
const contextValue = useMemo(
() => ( { __experimentalWithBlockNavigationSlots } ),
[ __experimentalWithBlockNavigationSlots ]
() => ( {
__experimentalWithBlockNavigationSlots,
__experimentalWithEllipsisMenu,
} ),
[
__experimentalWithBlockNavigationSlots,
__experimentalWithEllipsisMenu,
]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default function NavigationStructurePanel( { blocks, initialOpen } ) {
selectedBlockClientId={ selectedBlockClientIds[ 0 ] }
selectBlock={ selectBlock }
__experimentalWithBlockNavigationSlots={ true }
__experimentalWithEllipsisMenu={ true }
showNestedBlocks
showAppender
showBlockMovers
Expand Down

0 comments on commit 691c486

Please sign in to comment.