Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Setttings Menu Controls: Add unstableDisplayLocation prop. #43987

Merged
merged 5 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ function ReusableBlocksMenuItems() {
);
}
```

## Props

### `__unstableDisplayLocation`

- **Type:** `String`
- **Default:** `undefined`

A string representing the location where the component is being displayed within the UI. This can be used to conditionalize certain behaviors including the display of associated components. This behaviour will likely be refactored to a React.Context implementation.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ import { store as blockEditorStore } from '../../store';

const { Fill, Slot } = createSlotFill( 'BlockSettingsMenuControls' );

const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
const BlockSettingsMenuControlsSlot = ( {
fillProps,
clientIds = null,
__unstableDisplayLocation,
} ) => {
const { selectedBlocks, selectedClientIds, canRemove } = useSelect(
( select ) => {
const {
Expand Down Expand Up @@ -58,7 +62,14 @@ const BlockSettingsMenuControlsSlot = ( { fillProps, clientIds = null } ) => {
( isGroupable || isUngroupable ) && canRemove;

return (
<Slot fillProps={ { ...fillProps, selectedBlocks, selectedClientIds } }>
<Slot
fillProps={ {
...fillProps,
__unstableDisplayLocation,
selectedBlocks,
selectedClientIds,
} }
>
{ ( fills ) => {
if (
! fills?.length > 0 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export function BlockSettingsDropdown( {
clientIds,
__experimentalSelectBlock,
children,
__unstableDisplayLocation,
...props
} ) {
const blockClientIds = castArray( clientIds );
Expand Down Expand Up @@ -289,6 +290,9 @@ export function BlockSettingsDropdown( {
<BlockSettingsMenuControls.Slot
fillProps={ { onClose } }
clientIds={ clientIds }
__unstableDisplayLocation={
__unstableDisplayLocation
}
/>
{ typeof children === 'function'
? children( { onClose } )
Expand Down