Skip to content

Commit

Permalink
Fix resetting of opacity when cover has media background
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronrobertshaw committed Jun 6, 2022
1 parent 6b05ca5 commit f400907
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/block-library/src/cover/edit/inspector-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,20 @@ export default function CoverInspectorControls( {
{ ...colorGradientSettings }
/>
<ToolsPanelItem
hasValue={ () => !! dimRatio }
hasValue={ () => {
// If there's a media background the dimRatio will be
// defaulted to 50 whereas it will be 100 for colors.
return dimRatio === undefined
? false
: dimRatio !== ( url ? 50 : 100 );
} }
label={ __( 'Overlay opacity' ) }
onDeselect={ () =>
setAttributes( { dimRatio: undefined } )
setAttributes( { dimRatio: url ? 50 : 100 } )
}
resetAllFilter={ () => ( { dimRatio: undefined } ) }
resetAllFilter={ () => ( {
dimRatio: url ? 50 : 100,
} ) }
isShownByDefault
panelId={ clientId }
>
Expand Down

0 comments on commit f400907

Please sign in to comment.