Skip to content

Commit

Permalink
[Block Settings]: Show move to on nested blocks when only one root …
Browse files Browse the repository at this point in the history
…block (#44827)

* [Block Settings]: Show `move to` on nested blocks when only one root block

* use `getBlockRootClientId`
  • Loading branch information
ntsekouras authored Oct 10, 2022
1 parent 38d946a commit 029d296
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function BlockSettingsDropdown( {
const {
getBlockCount,
getBlockName,
getBlockParents,
getBlockRootClientId,
getPreviousBlockClientId,
getNextBlockClientId,
getSelectedBlockClientIds,
Expand All @@ -84,19 +84,22 @@ export function BlockSettingsDropdown( {

const { getActiveBlockVariation } = select( blocksStore );

const parents = getBlockParents( firstBlockClientId );
const _firstParentClientId = parents[ parents.length - 1 ];
const parentBlockName = getBlockName( _firstParentClientId );
const _firstParentClientId =
getBlockRootClientId( firstBlockClientId );
const parentBlockName =
_firstParentClientId && getBlockName( _firstParentClientId );

return {
firstParentClientId: _firstParentClientId,
isDistractionFree: getSettings().isDistractionFree,
onlyBlock: 1 === getBlockCount(),
onlyBlock: 1 === getBlockCount( _firstParentClientId ),
parentBlockType:
getActiveBlockVariation(
_firstParentClientId &&
( getActiveBlockVariation(
parentBlockName,
getBlockAttributes( _firstParentClientId )
) || getBlockType( parentBlockName ),
) ||
getBlockType( parentBlockName ) ),
previousBlockClientId:
getPreviousBlockClientId( firstBlockClientId ),
nextBlockClientId: getNextBlockClientId( firstBlockClientId ),
Expand Down Expand Up @@ -221,7 +224,7 @@ export function BlockSettingsDropdown( {
<__unstableBlockSettingsMenuFirstItem.Slot
fillProps={ { onClose } }
/>
{ firstParentClientId !== undefined && (
{ !! firstParentClientId && (
<MenuItem
{ ...showParentOutlineGestures }
ref={ selectParentButtonRef }
Expand Down

0 comments on commit 029d296

Please sign in to comment.