-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Try providing a non-zero value for client width in image editor. #51285
Conversation
Size Change: +122 B (0%) Total Size: 1.39 MB
ℹ️ View Unchanged
|
If I read this fix correctly, then it's a good improvement and just needs a code sanity check. Images should never collapse into black holes. Speaking of, I vaguely recall a similar issue with some embeds, notably responsive video embeds, which we've currently patched up with a min-width bandaid. Would a fix like this work there as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix, this is testing great for me, too!
✅ Cropping tools work correctly on image block in flow content
✅ Cropping tools work correctly on image block within a Gallery block
✅ Cropping tools work correctly on image block within a Row block
✅ Cropping tools work correctly on image block with custom width set
2023-06-08.09.08.34.mp4
Looks good to me, and if we run into any issues, it'll be an easy revert! LGTM ✨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix, this is testing great for me, too!
✅ Cropping tools work correctly on image block in flow content
✅ Cropping tools work correctly on image block within a Gallery block
✅ Cropping tools work correctly on image block within a Row block
✅ Cropping tools work correctly on image block with custom width set
2023-06-08.09.08.34.mp4
Looks good to me, and if we run into any issues, it'll be an easy revert! LGTM ✨
Co-authored-by: Andrew Serong <[email protected]>
Hmm the Video block doesn't use the cropping library or the width calculations that were causing this issue in the Image block, so it's unlikely. |
Thanks for reviewing and testing, folks! |
…dPress#51285) * Try removing align value from clientWidth hook * Try providing a non-zero value for client width. * Remove empty line. * Fix typo Co-authored-by: Andrew Serong <[email protected]> --------- Co-authored-by: Andrew Serong <[email protected]>
What?
Fixes #51250.
The initial calculation from useClientWidth hook is sometimes zero, and we don't want it to recalculate every time image width changes because it can go into an infinite loop. The problem is that clientWidth provides the dimensions for the image editor so, if that value is zero, the image editor is 0px wide.
I've tried to fix that by instead passing the current width of the image to the image editor, with client width as a fallback in case that's undefined. I've tested with images inside and outside of flex and non-flex containers, and with different alignments, and it seems to work fine in all cases, but would be good to test further!
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast