Opened 103 minutes ago
Last modified 99 minutes ago
#66874 new defect (bug)
Editor: Classic themes without editor styles lose the default editor font
| Reported by: | ramonopoly | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.3 |
| Component: | Editor | Version: | 7.0 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
In the post editor, a classic theme with no theme.json and no editor styles shows the post content in the browser's default serif font at 16px. It should show the default editor styles: the system font at 18px.
Steps to reproduce
- Activate a classic theme that has no
theme.jsonand does not calladd_theme_support( 'editor-styles' ). A theme with only astyle.cssheader and an emptyindex.phpis enough. - Create a post with a paragraph and open it in the block editor.
- Inspect the paragraph in the editor canvas.
Expected: the system font at 18px, from the defaultEditorStyles setting.
Actual: serif at 16px with line-height: normal.
Cause
Since #64408 and wordpress-develop PR 10623 (the backport of Gutenberg PR 73971, which enabled global styles for classic themes), get_block_editor_settings() adds the generated global stylesheet with '__unstableType' => 'theme' for every theme. The post editor only falls back to defaultEditorStyles when the settings contain no styles of that type, so it now treats every classic theme as having its own editor styles, and the defaults are never applied.
Before that change, themes without theme.json got a stylesheet typed 'base-layout', and the defaults were applied.
[65749] (#66762) restored the contents of defaultEditorStyles, which had become empty. That fixed the editor when "Use theme styles" is turned off, and the Customizer widgets editor. It does not fix this case, where the preference is on.
Proposed fix
In get_block_editor_settings(), when the context is the post editor with a post, the theme has no theme.json, and get_block_editor_theme_styles() returns nothing, add the defaultEditorStyles entries to the start of the styles setting, typed 'theme'.
- Placed first, so global styles still override them.
- Typed
'theme', so turning off "Use theme styles" still leaves only the default editor styles, with no duplicate.
This is the approach in Gutenberg PR 87629, which fixes Gutenberg issue 79815. This ticket is for the same change in core.
Change History (1)
This ticket was mentioned in PR #16330 on WordPress/wordpress-develop by @ramonopoly.
99 minutes ago
#1
- Keywords has-patch has-unit-tests added
Backports https://github.com/WordPress/gutenberg/pull/87629.
What?
In the post editor, a classic theme with no
theme.jsonand no editor styles shows the content in the browser's default serif font at 16px.get_block_editor_settings()now adds thedefaultEditorStylesentries to the start of thestylessetting for these themes, typed'theme'.'theme': when "Use theme styles" is turned off, the editor drops them and usesdefaultEditorStyleson its own, so the defaults are not doubled.Why?
Since #64408, the generated global stylesheet is typed
'theme'for every theme. The post editor only usesdefaultEditorStyleswhen there are no styles of that type, so it never applies them for classic themes.Scope
Only the post editor: the
core/edit-postcontext with a post. The widgets editor, the site editor and the/wp-block-editor/v1/settingsendpoint (which usescore/edit-postwithout a post) are not changed.Testing
npm run test:php -- --group 66874Manual:
theme.jsonand noadd_theme_support( 'editor-styles' ). A theme with only astyle.cssheader and an emptyindex.phpis enough.serifat 16px. With this PR it is the system font at 18px.