-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Enqueue preset styles for all themes in the editor #35424
Enqueue preset styles for all themes in the editor #35424
Conversation
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.
This tests fine for me!
ff10d3b
to
e265764
Compare
if ( | ||
'site-editor' !== $context && | ||
'mobile' !== $context && | ||
( WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() || get_theme_support( 'experimental-link-color' ) ) |
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.
We no longer need to check for theme.json
presence of legacy link color support, because we now enqueue the preset styles for all themes.
We can also simplify the double negation by using all
instead.
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 change makes sense to me 👍
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.
Still works after the update!
This inadvertently introduced a bug for themes that do not provide any editor styles. See #35730 (comment) and potential fixes #35736 and #35737 |
Follow-up to #34334
This fixes a bug by which preset classes were not added to the editor for all themes.
In #34334 I missed enqueueing the preset classes in the editor for all themes. When they were removed from the
base-style
package at #34510 they started to be missing in the editor.Why this wasn't noticeable before
In the editor, when the user selects a color from the preset palette, classes are added to it. The block also gets inline styles for legacy reasons. That we inline styles hid the fact that we were not enqueueing preset classes in the editor.
Setup affected by this bug
This only affected blocks that don't use our support hooks (so they don't get inline styles) when the active theme is a classic one (no theme.json or legacy link color support) that also delegated the enqueueing of preset classes to core (either because they don't define any preset or because they do but don't enqueue it themselves). A example of this is the Storefront theme.
This was introduced in Gutenberg 11.5.
How to test
The expected result is that the paragrah still has the colors applied (because the classes are now in scope).
Another check you can do is to verify the core classes are present, such as:
.has-vivid-red-color
,.has-luminous-vivid-orange-background-color
, etc. See full list of colors. The classes generated are in the form of.has-$slug-color
,.has-$slug-background-color
.