Skip to content

Commit

Permalink
Resetting position if it's center and size is not contain.
Browse files Browse the repository at this point in the history
We don't use named values yet, only percentages, so it should be safe
  • Loading branch information
ramonjd committed Mar 22, 2024
1 parent 3872394 commit b09f29e
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,16 @@ function BackgroundSizeToolsPanelItem( {
const updateBackgroundSize = ( next ) => {
// When switching to 'contain' toggle the repeat off.
let nextRepeat = repeatValue;
let nextPosition = positionValue;

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

if ( next !== 'contain' && nextPosition === 'center' ) {
nextPosition = undefined;
}

if ( next === 'cover' ) {
nextRepeat = undefined;
}
Expand All @@ -414,6 +419,7 @@ function BackgroundSizeToolsPanelItem( {
onChange(
setImmutably( style, [ 'background' ], {
...style?.background,
backgroundPosition: nextPosition,
backgroundRepeat: nextRepeat,
backgroundSize: next,
} )
Expand Down

0 comments on commit b09f29e

Please sign in to comment.