Skip to content

Commit

Permalink
Grab clientId from context instead of requiring a prop
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Apr 29, 2020
1 parent b54cf0f commit 9352479
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 6 additions & 4 deletions packages/block-editor/src/components/block-navigation/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ import { isNil, map, omitBy } from 'lodash';
* WordPress dependencies
*/
import { Slot, Fill } from '@wordpress/components';
import { Children, cloneElement } from '@wordpress/element';
import { Children, cloneElement, useContext } from '@wordpress/element';

/**
* Internal dependencies
*/
import ListItem from './list-item';
import ButtonBlockAppender from '../button-block-appender';
import { BlockListBlockContext } from '../block-list/block';

const listItemSlotName = ( blockId ) => `BlockNavigationList-item-${ blockId }`;

export const ListItemSlot = ( { blockId, ...props } ) => (
<Slot { ...props } name={ listItemSlotName( blockId ) } />
);
export const ListItemFill = ( { blockId, ...props } ) => (
<Fill { ...props } name={ listItemSlotName( blockId ) } />
);
export const ListItemFill = ( props ) => {
const { clientId } = useContext( BlockListBlockContext );
return <Fill { ...props } name={ listItemSlotName( clientId ) } />;
};

export default function BlockNavigationList( {
blocks,
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/navigation-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const noop = () => {};

function NavigationLinkEdit( {
attributes,
clientId,
hasDescendants,
isSelected,
isParentOfSelectedBlock,
Expand Down Expand Up @@ -223,7 +222,7 @@ function NavigationLinkEdit( {
/>
</PanelBody>
</InspectorControls>
<BlockNavigationListItemFill blockId={ clientId }>
<BlockNavigationListItemFill>
<BlockNavigationListItem
wrapperComponent="div"
onClick={ noop }
Expand Down

0 comments on commit 9352479

Please sign in to comment.