Skip to content

Commit

Permalink
Background image support: Fix issue with background position if keybo…
Browse files Browse the repository at this point in the history
…ard entry happens before mouse interaction (#59050)

Co-authored-by: andrewserong <[email protected]>
Co-authored-by: tellthemachines <[email protected]>
  • Loading branch information
3 people authored Feb 15, 2024
1 parent dffac59 commit 626f7c7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/block-editor/src/hooks/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,14 @@ function backgroundSizeHelpText( value ) {
}

export const coordsToBackgroundPosition = ( value ) => {
if ( ! value || isNaN( value.x ) || isNaN( value.y ) ) {
if ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {
return undefined;
}

return `${ value.x * 100 }% ${ value.y * 100 }%`;
const x = isNaN( value.x ) ? 0.5 : value.x;
const y = isNaN( value.y ) ? 0.5 : value.y;

return `${ x * 100 }% ${ y * 100 }%`;
};

export const backgroundPositionToCoords = ( value ) => {
Expand Down

1 comment on commit 626f7c7

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 626f7c7.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7911192048
📝 Reported issues:

Please sign in to comment.