-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Bugfix/70733 add white backing in editor #71570
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
base: trunk
Are you sure you want to change the base?
Conversation
|
Size Change: +200 B (+0.01%) Total Size: 2.04 MB
ℹ️ View Unchanged
|
|
|
||
| .block-editor-block-preview__content-iframe { | ||
| // Ensure a white backing layer for consistent semi-transparent color blending | ||
| background-color: $white; |
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's a brief flash of the darker colour while this loads 🤔
|
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. |
|
Flaky tests detected in 562efcb. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18498117312
|
|
Why doesn’t setting the iframe to white work? |
|
I see, I guess because of zoom out. |
|
Sorry I’m mobile atm. To what element are global styles backgrounds applied? Is it the body? If so, could we make the html element white? |
| position: absolute; | ||
| inset: 0; | ||
| background-color: $white; | ||
| } |
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.
Why is this added a second time? Maybe it needs 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.
Also isn't .editor-visual-editor outside the iframe? Why does it need to use a pseudo element here?
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.
The white background-color should be applied between the body element (which gets the theme background-color applied) and any Gutenberg chrome. This ensures the behaviour is as close as possible to the front-end site (though technically speaking "white" here is UA dependent).
The GB chrome is implemented in different ways in different modes. Focusing purely on background-color:
- The general editor sets
iframe.edit-site-visual-editor__editor-canvasto be transparent and so the.editor-visual-editorbackground-color shines through. - The template part editor (e.g. header editing) sets some of its styling inside the iframe - it sets a background-color on
iframe.edit-site-visual-editor__editor-canvas html.block-editor-iframe__html - The style editing mode sets the iframe.edit-site-visual-editor__editor-canvas to transparent and so the
.edit-site-layout:not(.is-full-canvas) .editor-visual-editorbackground-color shines through - The zoomed-out mode (e.g. pattern inserter) sets some of its styling inside the iframe too - it sets a background-color on
html.edit-site-visual-editor__editor-canvas iframe.block-editor-iframe__html.is-zoomed-out(as well as setting background-color:initial)
In short, it's repeated because the background in gutenberg is complicated and handled diffusely (though the new --wp-editor-canvas-background variable consolidates it somewhat).
I considered the comment for the background-color above it to cover the explanation as to why it's repeated.
I think you're right about this not needing to be use a pseudo element. The iframe itself could probably just be set below to use $white.
4052552 to
6548105
Compare
This variable was not defined inside the iframe, and hence the grey background was not being set in zoomed-out mode.
6548105 to
562efcb
Compare

What?
Closes #70733
It's worth pointing out that this PR is a step forward to aligning GB with the front-end, but isn't likely to be completely exhaustive in reference to treatment of alpha transparency on site elements.
Adds white "backing layers" to the editor canvas so that semi-transparent site background colours blend accurately and match the frontend.
Why?
The site editor canvas isn't always white - when inserting patterns, normal template editing or using the left hand navigation to change things. This causes transparent RGBA site backgrounds (e.g., #F5F6FE30) to blend against that background instead of the intended white, leading to a visible color mismatch between the editor and the frontend.
This change builds upon an unmerged PR #70737 that @R1shabh-Gupta started and @t-hamano reviewed.
How?
Testing Instructions
Screenshots or screencast
(Using a test background colour of
#503aa830)