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

Image block not resizing correctly #37374

Open
ice9js opened this issue Dec 14, 2021 · 11 comments
Open

Image block not resizing correctly #37374

ice9js opened this issue Dec 14, 2021 · 11 comments
Labels
[Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended

Comments

@ice9js
Copy link
Contributor

ice9js commented Dec 14, 2021

Description

I noticed the image block breaks when you attempt to resize it if Insert from URL feature was used and the image is using left, right or center align.
The image appears fine in the editor but you'll notice negative values for width and height in the sidebar - once you reload the editor or go into the preview the image will be sized differently.

Step-by-step reproduction instructions

  1. In the post editor, add a regular image block (core/image).
  2. Use Insert from URL option in the image placeholder to insert an image from a URL.
  3. Select Align Left, Align Right or Align Center from the alignment options in the toolbar.
  4. Resize the image by grabbing one of the handles at the edge and moving it.
  5. Watch width and height settings in the sidebar while you're resizing it.

Note: I noticed that if I start resizing an image as soon as I add it and then change block alignment, the bug no longer occurs.

Screenshots, screen recording, code snippet

Screen Shot 2021-12-14 at 3 09 20 PM

Environment info

I've noticed this issue on WordPress 5.9-beta2-52363 as well as Gutenberg 12.1.0.

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@glendaviesnz glendaviesnz added [Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended labels Dec 15, 2021
@glendaviesnz
Copy link
Contributor

I wasn't able to replicate this on the latest GB trunk:

resize

I wonder if it was fixed by #37210, @ice9js is it possible for you to retest in an environment with a build of the latest GB trunk?

@MadtownLems
Copy link

@glendaviesnz - Are you able to re-test with one minor tweak?

I am experiencing the same negative width/height when an aligned image is resized SMALLER. (It actually doesn't matter if it's from URL or media library). But a key part of the problem is that the FIRST drag-to-resize needs to be smaller, not larger.

When I align an image, then drag it smaller, I get negative a negative width and height.

@MadtownLems
Copy link

I have confirmed this bug still exists on 5.9 (no Gutenberg plugin).

Simply:
Add an Image Block
Select an Image
Align it Right
Drag to Resize it Smaller.
Notice that you now have negative image dimensions set.

@Mamaduka
Copy link
Member

Mamaduka commented Feb 3, 2022

Here are my results. WP 5.9 without Gutenberg.

CleanShot.2022-02-03.at.20.30.50.mp4

@MadtownLems
Copy link

And here's my screencast. ( also WP 5.9 without gutenberg 🤔)

negative-widths.mp4

@glendaviesnz
Copy link
Contributor

Thanks for the extra detail @MadtownLems, I was able to replicate this on GB trunk if I make the image smaller first. Interesting that it is fine for you @Mamaduka, I wonder if it is something to do with the original dimensions/aspect ratio of the image as well? I will try and take a closer look at it today.

@glendaviesnz
Copy link
Contributor

I haven't had any luck tracking this down yet. For some reason, the ResizableBox component in some instances returns a negative value, even though the minHeight and minWidth values are positive values.

@Mamaduka
Copy link
Member

Mamaduka commented Feb 4, 2022

Thanks for the confirmations, @glendaviesnz.

I think narrowing down the "requirements" to constantly reproduce the issue will be very helpful for tracking this down

@glendaviesnz
Copy link
Contributor

I think narrowing down the "requirements" to constantly reproduce the issue will be very helpful for tracking this down

Yeh, it mostly did it for me, but sometimes didn't, and wasn't able to isolate what was the difference. I will take another look at it next week if someone else doesn't get to it.

@MadtownLems
Copy link

FWIW, I am no longer experiencing this particular image block sizing problem on 6.2

@perkele1989
Copy link

I am experiencing this issue on 6.2

Using an SVG, editing the header of a site using the theme Launchify.
When inspecting in HTML, it gets negative values. Results in a huge file. Cant change it to positive values in HTML because block editor says it got unexpected stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants