Skip to content

Commit

Permalink
Check for block support earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Jul 12, 2021
1 parent f888713 commit 6587407
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions packages/block-editor/src/hooks/duotone.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ ${ selector } {
);
}

function DuotonePanel( { name, attributes, setAttributes } ) {
function DuotonePanel( { attributes, setAttributes } ) {
const style = attributes?.style;
const duotone = style?.color?.duotone;

Expand All @@ -133,10 +133,7 @@ function DuotonePanel( { name, attributes, setAttributes } ) {
! useSetting( 'color.customDuotone' ) ||
( colorPalette?.length === 0 && disableCustomColors );

if (
! hasBlockSupport( name, 'color.__experimentalDuotone' ) ||
( duotonePalette?.length === 0 && disableCustomDuotone )
) {
if ( duotonePalette?.length === 0 && disableCustomDuotone ) {
return null;
}

Expand Down Expand Up @@ -199,10 +196,15 @@ function addDuotoneAttributes( settings ) {
*/
const withDuotoneControls = createHigherOrderComponent(
( BlockEdit ) => ( props ) => {
const hasDuotoneSupport = ! hasBlockSupport(
props.name,
'color.__experimentalDuotone'
);

return (
<>
<BlockEdit { ...props } />
<DuotonePanel { ...props } />
{ hasDuotoneSupport && <DuotonePanel { ...props } /> }
</>
);
},
Expand Down

0 comments on commit 6587407

Please sign in to comment.