-
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 CSS classes for the post editor iframe body. #68481
base: trunk
Are you sure you want to change the base?
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: +3 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
Fixes #60299
Second attempt to fix this issue after #60300 was reverted for a bug in Safari, see #60616. A follow-up was planned but it never happened.
What?
In the post editor, the
is-dark-theme
CSS class gets removed from the iframe body when the iframe fully loads. This happens only in the post editor, it doesn't in the site editor as the implementation is different.Why?
The
is-dark-theme
CSS class is necessary to correctly style some UIs when a dark theme is in use.For example, for accessibility, the block placeholder text should use a sufficient contrast ratio when the theme is dark.
How?
Moves setting the iframe body classes at an earlier time in
useRefEffect
rather than in the iframeonLoad
callback.I'm not sure there was a specific reason to set the classes after the iframe is fully loaded. The
onLoad
callback appears to be too late, as at that point the existing classes get replaced.In this PR the setting of the classes happens earlier, in the
useRefEffect
hook. It appears everything works as expected because at that point the iframe element is rendered. Theoretically there shouldn't be drawbacks but please double check any potential undesired side effect.Cc @glendaviesnz @ellatrix
Testing Instructions
Reproduce the issue on trunk:
load
event takes a while to fire.block-editor-iframe__body
to check the intial classes before the iframe fully loads are:block-editor-iframe__body editor-styles-wrapper is-dark-theme
block-editor-iframe__body editor-styles-wrapper post-type-post admin-color-fresh wp-embed-responsive
is-dark-theme
class is now missing.block-editor-iframe__body editor-styles-wrapper post-type-post admin-color-fresh wp-embed-responsive is-dark-theme
is-dark-theme
class isstill there.and observe the
admin-color-freshclass is now
admin-color-midnight`.post-type-post
class is nowpost-type-pag
.Testing Instructions for Keyboard
Screenshots or screencast