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
Prevent resizing from triggering re-renders #60583
Conversation
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
imageWidthWithinContainer = exceedMaxWidth ? clientWidth : naturalWidth; | ||
} | ||
|
||
if ( ! isResizable || ! imageWidthWithinContainer ) { |
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.
I'm not sure I understood this condition. imageWidthWithinContainer
returns either clientWidth
or naturalWidth
. Which will always be a number unless something went wrong with the image loading. So a check for ! naturalWidth || ! naturalHeight
should be enough here.
Size Change: +66 B (0%) Total Size: 1.73 MB
ℹ️ View Unchanged
|
What?
Why?
All this work getting done, seemingly because of an innocent
calculateClientWidth
. Although I'm having a hard time figuring out why React is re-rendering so many things, it should be contained within the image and site logo blocks.first run -2.90%, second run -5.65% (template replace)
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast