fix(newsletters): render layout previews correctly in Safari/WebKit#274
Open
thomasguillot wants to merge 1 commit into
Open
fix(newsletters): render layout previews correctly in Safari/WebKit#274thomasguillot wants to merge 1 commit into
thomasguillot wants to merge 1 commit into
Conversation
a5241f6 to
a817ea5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
Newsletter layout previews (the Layouts list DataView, the editor's layout sidebar, and the init-modal layout picker) rendered correctly in Chromium but broke in Safari/WebKit: the site logo blew out to its intrinsic size, social links lost their flex layout, the site-logo "Drop files to upload" overlay showed through, and custom layout fonts/colors fell back to defaults.
Root cause.
NewsletterPreviewgot the core editor stylesheets into theBlockPreviewiframe by hand-injecting<link>/<style>nodes into the iframe<head>on load. Gutenberg owns that iframe document and re-renders it, discarding anything injected outside its own channels. Chromium's timing left the injected nodes in place; WebKit wiped them, so the iframe was missing core block/editor CSS.Fix. Route styles through Gutenberg's own channels — the same way the Post/Site editors do — so they persist across browsers:
wp-block-library,-theme,wp-edit-blocks,wp-components) viasettings.__unstableResolvedAssets, referenced by URL and baked into the iframesrcDoc. Seeded only where that setting is empty (admin-shell surfaces) and never on the live editor, so the editor canvas is never reloaded.settings.stylesentry (safe{ css }, no raw HTML concatenation).BlockPreview'sadditionalStylesprop, with!importanton the generated rules so they win over both the seeded defaults and the editor's higher-specificity, variable-based font rules on the in-editor preview surfaces.This removes the WebKit-fragile hand-injection: the redundant stylesheet clone, the duplicated per-instance/global
<style>injection, and the dead#newspack-newsletters__layout-csselement (whose only consumer inposts-inserter/posts-preview.jsis also removed — that preview still gets fonts viauseCustomFontsInIframe). Net result is a smaller component with no per-block CSS patches.How to test the changes in this Pull Request:
editor.csscompetes;!importantensures the layout's styles win).Other information: