Skip to content

Commit

Permalink
Disable duotone until media is provided in Cover block
Browse files Browse the repository at this point in the history
  • Loading branch information
jrtashjian committed Sep 14, 2023
1 parent 21b6a37 commit 5fe0683
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/block-editor/src/hooks/duotone.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,16 @@ function DuotonePanel( { attributes, setAttributes, name } ) {
return null;
}

// Ensures media details exist in specific blocks; if they're missing, it hides the control.
const blockNamesToCheck = [ 'core/cover', 'core/image' ];
const requiredAttributes = [ 'id', 'useFeaturedImage' ];
if (
blockNamesToCheck.includes( name ) &&
! requiredAttributes.some( ( key ) => attributes?.[ key ] )
) {
return null;
}

const duotonePresetOrColors = ! Array.isArray( duotoneStyle )
? getColorsFromDuotonePreset( duotoneStyle, duotonePalette )
: duotoneStyle;
Expand Down

0 comments on commit 5fe0683

Please sign in to comment.