-
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
Fix safari bug with classes not being added to iframe elements #60550
Conversation
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. |
Size Change: +52 B (0%) Total Size: 1.73 MB
ℹ️ View Unchanged
|
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.
Is this a documented bug / problem for webkit? I want to be sure we're not doing something the wrong way before we rely on retries and polling ❓
oh, that would be helpful! 😄 I can't find anything specific in the webkit bug tracker, and there are just a few vague references to it on the odd stack overflow post.
Yep, me too. I have 🤞 that there is an alternative to the retry, but haven't had much luck trying to find one so far. I can't see that we are doing something obviously wrong here. In Safari's case it is like we need an onload listener on node.contentDocument instead, or using |
Have also tried:
and for Safari node.contentDocument.body is regularly |
@glendaviesnz We shouldn't check the iframe body because we actually remove that ourselves. That's because we render the body with React and need to avoid two body elements.
So we should remove all this logic introduced last week here because it's not possible to have initial body classes: If you remove that logic, it will fix the error, and your issue. |
thanks for the follow up @ellatrix. Closing this in favour of #60616 I think the |
What?
Often in Safari the correct styles are not applied to the editor iframe elements. This currently only shows itself in zoomed out mode as the
.block-editor-iframe__html
class is not applied, so the required transformation styles to make zoomed out mode work are not applied.You might need to refresh the browser several times to see the issue, it does not happen with every load.
Why?
Sometimes Safari fires the load event before
contentDocument
is properly loaded in the iFrame, so acontentDocument.body
is null exception is thrown and the correct classes are not applied.How?
Checks that
contentDocument.body !== null
and if it is runonLoad
again after a timeout.Testing Instructions
Screenshots or screencast
Before:
zoom-before.mp4
After:
zoom-after.mov