-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Image block: Add guard for null refs in setButtonStyles callback
#72715
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
Conversation
|
Size Change: +14 B (0%) Total Size: 2.37 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in b302e84. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18846636838
|
luisherranz
left a comment
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.
LGTM!
|
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. |
Co-authored-by: DAreRodz <darerodz@git.wordpress.org> Co-authored-by: luisherranz <luisherranz@git.wordpress.org>
|
I just cherry-picked this PR to the wp/6.9 branch to get it included in the next release: 612afc3 |
What?
Fixes a bug in Image blocks with the "expand on click" option enabled. The bug appears when an interactive image is removed from the DOM, e.g., when you navigate in a Query block with the "Reload full page" option disabled, and the
setButtonStylescallback is triggered because of aloadevent.Why?
The error is visible in production. Also, now that the Content block is enabled inside a Query block with the "Reload full page" option disabled, this case is likely to happen.
How?
The bug fix checks if
refexists when calling thesetButtonStylescallback. We need to do so because Preact doesn't removeloadevent listeners on images by default (see preactjs/preact#3141), and theloadevent could be dispatched multiple times for the same element if it has asrcsetattribute.The ideal way to solve this would be to handle this specific case inside the
data-wp-ondirective. However, this would require agreeing on the desired behavior first, as it would mean changing Preact's default behavior.Testing Instructions