Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Hide variation selector for section blocks
  • Loading branch information
talldan committed Sep 10, 2025
commit 361f6333d13702ffddc16437de9735b2ed8dd854
Original file line number Diff line number Diff line change
Expand Up @@ -139,32 +139,40 @@ function VariationsToggleGroupControl( {

function __experimentalBlockVariationTransforms( { blockClientId } ) {
const { updateBlockAttributes } = useDispatch( blockEditorStore );
const { activeBlockVariation, variations, isContentOnly } = useSelect(
( select ) => {
const { getActiveBlockVariation, getBlockVariations } =
select( blocksStore );

const { getBlockName, getBlockAttributes, getBlockEditingMode } =
select( blockEditorStore );

const name = blockClientId && getBlockName( blockClientId );

const { hasContentRoleAttribute } = unlock( select( blocksStore ) );
const isContentBlock = hasContentRoleAttribute( name );

return {
activeBlockVariation: getActiveBlockVariation(
name,
getBlockAttributes( blockClientId )
),
variations: name && getBlockVariations( name, 'transform' ),
isContentOnly:
getBlockEditingMode( blockClientId ) === 'contentOnly' &&
! isContentBlock,
};
},
[ blockClientId ]
);
const { activeBlockVariation, variations, isContentOnly, isSection } =
useSelect(
( select ) => {
const { getActiveBlockVariation, getBlockVariations } =
select( blocksStore );

const {
getBlockName,
getBlockAttributes,
getBlockEditingMode,
} = select( blockEditorStore );
const { isSectionBlock } = unlock( select( blockEditorStore ) );

const name = blockClientId && getBlockName( blockClientId );

const { hasContentRoleAttribute } = unlock(
select( blocksStore )
);
const isContentBlock = hasContentRoleAttribute( name );

return {
activeBlockVariation: getActiveBlockVariation(
name,
getBlockAttributes( blockClientId )
),
variations: name && getBlockVariations( name, 'transform' ),
isContentOnly:
getBlockEditingMode( blockClientId ) ===
'contentOnly' && ! isContentBlock,
isSection: isSectionBlock( blockClientId ),
};
},
[ blockClientId ]
);

const selectedValue = activeBlockVariation?.name;

Expand All @@ -189,7 +197,7 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
} );
};

if ( ! variations?.length || isContentOnly ) {
if ( ! variations?.length || isContentOnly || isSection ) {
return null;
}

Expand Down