We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 00f7e12 commit 9b48e86Copy full SHA for 9b48e86
packages/block-editor/src/hooks/background.js
@@ -374,11 +374,14 @@ function backgroundSizeHelpText( value ) {
374
}
375
376
export const coordsToBackgroundPosition = ( value ) => {
377
- if ( ! value || isNaN( value.x ) || isNaN( value.y ) ) {
+ if ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {
378
return undefined;
379
380
381
- return `${ value.x * 100 }% ${ value.y * 100 }%`;
+ const x = isNaN( value.x ) ? 0.5 : value.x;
382
+ const y = isNaN( value.y ) ? 0.5 : value.y;
383
+
384
+ return `${ x * 100 }% ${ y * 100 }%`;
385
};
386
387
export const backgroundPositionToCoords = ( value ) => {
0 commit comments