Skip to content

Commit

Permalink
Support for arbitrary clientIds in BlockSettingsMenuControlsSlot
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed May 20, 2020
1 parent 530410b commit d761f4c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ const { Fill: BlockSettingsMenuControls, Slot } = createSlotFill(
'BlockSettingsMenuControls'
);

const BlockSettingsMenuControlsSlot = ( { fillProps } ) => {
const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
const { selectedBlocks } = useSelect( ( select ) => {
const { getBlocksByClientId, getSelectedBlockClientIds } = select(
'core/block-editor'
);
const ids =
clientIds !== null ? clientIds : getSelectedBlockClientIds();
return {
selectedBlocks: map(
getBlocksByClientId( getSelectedBlockClientIds() ),
getBlocksByClientId( ids ),
( block ) => block.name
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export function BlockSettingsDropdown( { clientIds, ...props } ) {
</MenuGroup>
<BlockSettingsMenuControls.Slot
fillProps={ { onClose } }
clientIds={ clientIds }
/>
<MenuGroup>
{ ! isLocked && (
Expand Down

0 comments on commit d761f4c

Please sign in to comment.