Skip to content

Commit 6699665

Browse files
committed
When switching to "Tile" in the background size toggle, roll back default background size of 50%, and introduce a default background position of "50% 0"
1 parent 53e8b79 commit 6699665

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ function BackgroundSizeToolsPanelItem( {
426426
const updateBackgroundSize = ( next ) => {
427427
// When switching to 'contain' toggle the repeat off.
428428
let nextRepeat = repeatValue;
429+
let nextPosition = positionValue;
429430

430431
if ( next === 'contain' ) {
431432
nextRepeat = 'no-repeat';
@@ -441,7 +442,15 @@ function BackgroundSizeToolsPanelItem( {
441442
next === 'auto'
442443
) {
443444
nextRepeat = undefined;
444-
next = !! style?.background?.backgroundImage?.id ? '50%' : next;
445+
/*
446+
* A background image uploaded and set in the editor (an image with a record id),
447+
* receives a default background position of '50% 0',
448+
* when the toggle switches to "Tile". This is to increase the chance that
449+
* the image's focus point is visible.
450+
*/
451+
if ( !! style?.background?.backgroundImage?.id ) {
452+
nextPosition = '50% 0';
453+
}
445454
}
446455

447456
/*
@@ -455,6 +464,7 @@ function BackgroundSizeToolsPanelItem( {
455464
onChange(
456465
setImmutably( style, [ 'background' ], {
457466
...style?.background,
467+
backgroundPosition: nextPosition,
458468
backgroundRepeat: nextRepeat,
459469
backgroundSize: next,
460470
} )

0 commit comments

Comments
 (0)