Skip to content

Commit

Permalink
Only allow resetting scale when it is not the default value
Browse files Browse the repository at this point in the history
  • Loading branch information
stacimc committed Nov 17, 2021
1 parent e4e2ca8 commit b5ab519
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const SCALE_OPTIONS = (
</>
);

const DEFAULT_SCALE = 'cover';

const scaleHelp = {
cover: __(
'Image is scaled and cropped to fill the entire space without being distorted.'
Expand Down Expand Up @@ -74,12 +76,12 @@ const DimensionControls = ( {
onDeselect={ () =>
setAttributes( {
height: undefined,
scale: 'cover',
scale: DEFAULT_SCALE,
} )
}
resetAllFilter={ () => ( {
height: undefined,
scale: 'cover',
scale: DEFAULT_SCALE,
} ) }
isShownByDefault={ true }
panelId={ clientId }
Expand Down Expand Up @@ -119,15 +121,15 @@ const DimensionControls = ( {
</ToolsPanelItem>
{ !! height && (
<ToolsPanelItem
hasValue={ () => !! scale }
hasValue={ () => !! scale && scale !== DEFAULT_SCALE }
label={ scaleLabel }
onDeselect={ () =>
setAttributes( {
scale: 'cover',
scale: DEFAULT_SCALE,
} )
}
resetAllFilter={ () => ( {
scale: 'cover',
scale: DEFAULT_SCALE,
} ) }
isShownByDefault={ true }
panelId={ clientId }
Expand Down

0 comments on commit b5ab519

Please sign in to comment.