Skip to content

Commit

Permalink
Hide repeat toggle when using cover, ensure updating fixed size doesn…
Browse files Browse the repository at this point in the history
…'t change repeat value
  • Loading branch information
andrewserong committed Dec 21, 2023
1 parent becb2e8 commit 10ac7f8
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions packages/block-editor/src/hooks/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,19 @@ function BackgroundSizePanelItem( {

const updateBackgroundSize = ( next ) => {
// When switching to 'contain' toggle the repeat off.
const nextRepeat = next === 'contain' ? 'no-repeat' : undefined;
let nextRepeat = repeatValue;

if ( next === 'contain' ) {
nextRepeat = 'no-repeat';
}

if (
( currentValueForToggle === 'cover' ||
currentValueForToggle === 'contain' ) &&
next === 'auto'
) {
nextRepeat = undefined;
}

setAttributes( {
style: cleanEmptyObject( {
Expand Down Expand Up @@ -482,12 +494,14 @@ function BackgroundSizePanelItem( {
value={ sizeValue }
/>
) : null }
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Repeat image' ) }
checked={ repeatCheckedValue }
onChange={ toggleIsRepeated }
/>
{ currentValueForToggle !== 'cover' && (
<ToggleControl
__nextHasNoMarginBottom
label={ __( 'Repeat image' ) }
checked={ repeatCheckedValue }
onChange={ toggleIsRepeated }
/>
) }
</VStack>
);
}
Expand Down

0 comments on commit 10ac7f8

Please sign in to comment.