Skip to content

Commit b09f29e

Browse files
committed
Resetting position if it's center and size is not contain.
We don't use named values yet, only percentages, so it should be safe
1 parent 3872394 commit b09f29e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/block-editor/src/components/global-styles/background-panel.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,16 @@ function BackgroundSizeToolsPanelItem( {
394394
const updateBackgroundSize = ( next ) => {
395395
// When switching to 'contain' toggle the repeat off.
396396
let nextRepeat = repeatValue;
397+
let nextPosition = positionValue;
397398

398399
if ( next === 'contain' ) {
399400
nextRepeat = 'no-repeat';
400401
}
401402

403+
if ( next !== 'contain' && nextPosition === 'center' ) {
404+
nextPosition = undefined;
405+
}
406+
402407
if ( next === 'cover' ) {
403408
nextRepeat = undefined;
404409
}
@@ -414,6 +419,7 @@ function BackgroundSizeToolsPanelItem( {
414419
onChange(
415420
setImmutably( style, [ 'background' ], {
416421
...style?.background,
422+
backgroundPosition: nextPosition,
417423
backgroundRepeat: nextRepeat,
418424
backgroundSize: next,
419425
} )

0 commit comments

Comments
 (0)