From b09f29e5a183c7f983cf0e05df73531a169baefc Mon Sep 17 00:00:00 2001 From: ramon Date: Fri, 22 Mar 2024 16:40:51 +1100 Subject: [PATCH] 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 --- .../src/components/global-styles/background-panel.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/block-editor/src/components/global-styles/background-panel.js b/packages/block-editor/src/components/global-styles/background-panel.js index afd6e337898f1..17d9066067f79 100644 --- a/packages/block-editor/src/components/global-styles/background-panel.js +++ b/packages/block-editor/src/components/global-styles/background-panel.js @@ -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; } @@ -414,6 +419,7 @@ function BackgroundSizeToolsPanelItem( { onChange( setImmutably( style, [ 'background' ], { ...style?.background, + backgroundPosition: nextPosition, backgroundRepeat: nextRepeat, backgroundSize: next, } )