Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Media & Text Focal Point Picker Producing Long Decimal Values #33615

Closed
mrwweb opened this issue Jul 21, 2021 · 0 comments · Fixed by #33915
Closed

Media & Text Focal Point Picker Producing Long Decimal Values #33615

mrwweb opened this issue Jul 21, 2021 · 0 comments · Fixed by #33915
Labels
[Block] Media & Text Affects the Media & Text Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@mrwweb
Copy link

mrwweb commented Jul 21, 2021

Description

When setting a focal point on Media & Text blocks, the background-position value sometimes isn't rounded correctly. For examples:

  • 55.00000000000001% 50% for what should be 55% 50%
  • 56.99999999999999% 50% for what should be 57%, 50%

It does not impact every number. In my testing, I got the weird long decimals for 55-58% in both the X and Y axes.

This is extremely similar to an issue with Cover blocks in #18665 that was fixed in late 2019.

Step-by-step reproduction instructions

  1. Insert Media & Text Block
  2. Set at least one focal point value to between 55%-58%

Expected behaviour

Value in code matches value in UI.

Note: Attempting to fix the values in the code editor results in "This block contains unexpected or invalid content."

Actual behaviour

<!-- wp:media-text {"mediaId":8,"mediaLink":"https://playground.local/2012-04-22_11-21-16_856/","mediaType":"image","imageFill":true,"focalPoint":{"x":0.55,"y":"0.50"}} -->
<div class="wp-block-media-text alignwide is-stacked-on-mobile is-image-fill"><figure class="wp-block-media-text__media" style="background-image:url(https://playground.local/wp-content/uploads/2020/09/2012-04-22_11-21-16_856-1024x577.jpg);background-position:55.00000000000001% 50%"><img src="https://playground.local/wp-content/uploads/2020/09/2012-04-22_11-21-16_856-1024x577.jpg" alt="" class="wp-image-8 size-full"/></figure><div class="wp-block-media-text__content"><!-- wp:paragraph {"placeholder":"Content…","fontSize":"large"} -->
<p class="has-large-font-size">This is a block.</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:media-text -->

Screenshots or screen recording (optional)

image

WordPress information

  • WordPress version: 5.8
  • Gutenberg version: Not installed
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? Yes, Twenty Twenty

Device information

  • Device: Desktop
  • Operating system: Windows 10
  • Browser: Firefox 91
@Mamaduka Mamaduka added [Block] Media & Text Affects the Media & Text Block [Type] Bug An existing feature does not function as intended labels Jul 22, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Media & Text Affects the Media & Text Block [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants