Skip to content
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

Buttons: Add specificity for the editor #44731

Merged
merged 5 commits into from
Oct 7, 2022
Merged

Buttons: Add specificity for the editor #44731

merged 5 commits into from
Oct 7, 2022

Conversation

scruffian
Copy link
Contributor

What?

In #44334 we added styles for buttons in classic themes, but the styles were added with a global scope, whereas editor styles are usually added with a .editor-styles-wrapper selector, which makes them more specific. This changes the way we add the classic theme styles so that they also get wrapped in an .editor-styles-wrapper selector, matching the specificity.

Why?

This ensures that the button styles for classic themes are maintained so they don't lose their styling.

Testing Instructions

  1. Switch to a classic theme (like Twenty Ten)
  2. Add a button in the editor
  3. Check that the button looks the same as in the frontend (black background with white text and a pill shape in this case)
  4. Switch to a block theme
  5. Check that the classic theme styles don't load

Screenshots or screencast

Screenshot 2022-10-06 at 11 14 52

@scruffian scruffian added [Type] Bug An existing feature does not function as intended [Block] Buttons Affects the Buttons Block labels Oct 6, 2022
@scruffian scruffian self-assigned this Oct 6, 2022
Copy link
Contributor

@ajlende ajlende left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what I see in TwentyTen. It looks like the styles are applied correctly in the editor now and the frontend continues to look the same.

Editor

Before After
editor before editor after

Frontend

Before After
frontend before frontend after

It looks like there's still one doc comment error to fix, but once that's taken care of, this looks good to me.

@ockham ockham added the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 7, 2022
@scruffian scruffian merged commit d4fe76f into trunk Oct 7, 2022
@scruffian scruffian deleted the fix/44659 branch October 7, 2022 17:05
@github-actions github-actions bot added this to the Gutenberg 14.4 milestone Oct 7, 2022
ockham pushed a commit that referenced this pull request Oct 10, 2022
* Button elements: Add specificity for the editor

* only output on classic themes

* lint fixes

* add docblock

* return the editor settings on a block theme
@ockham
Copy link
Contributor

ockham commented Oct 10, 2022

I just cherry-picked this PR to the wp/6.1 branch to get it included in the next release: e2f4b7e

@ockham ockham removed the Backport to WP 6.7 Beta/RC Pull request that needs to be backported to the WordPress major release that's currently in beta label Oct 10, 2022
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 11, 2022
Package updates for bug and regression fixes:
@wordpress/block-directory: 3.15.6
@wordpress/block-editor: 10.0.6
@wordpress/block-library: 7.14.6
@wordpress/components: 21.0.5
@wordpress/customize-widgets: 3.14.6
@wordpress/edit-post: 6.14.6
@wordpress/edit-site: 4.14.8
@wordpress/edit-widgets: 4.14.6
@wordpress/editor: 12.16.6
@wordpress/format-library: 3.15.6
@wordpress/interface: 4.16.5
@wordpress/list-reusable-blocks: 3.15.5
@wordpress/nux: 5.15.5
@wordpress/preferences: 2.9.5
@wordpress/reusable-blocks: 3.15.6
@wordpress/server-side-render: 3.15.5
@wordpress/widgets: 2.15.6

References:
* [WordPress/gutenberg#43181 Gutenberg PR 43181] - Merge inner blocks if wrappers are equal
* [WordPress/gutenberg#44098 Gutenberg PR 44098] - Fix content blocks with nested blocks always appear as top level
* [WordPress/gutenberg#44150 Gutenberg PR 44150] - Refresh selection styles
* [WordPress/gutenberg#44415 Gutenberg PR 44415] - Removes `__unstableMaxPages` attribute from Page List and Nav blocks
* [WordPress/gutenberg#44463 Gutenberg PR 44463] - Follow discussion settings in the comments block edit
* [WordPress/gutenberg#44584 Gutenberg PR 44584] - Avoid querying block templates during installation
* [WordPress/gutenberg#44637 Gutenberg PR 44637] - Resizable editor: Fix height setting bug
* [WordPress/gutenberg#44640 Gutenberg PR 44640] - Only include theme.css if the theme declares support for wp-block-styles
* [WordPress/gutenberg#44650 Gutenberg PR 44650] - Fix empty links being created for the author's name comment
* [WordPress/gutenberg#44652 Gutenberg PR 44652] - Block Editor: Fix block search for non-Latin characters
* [WordPress/gutenberg#44660 Gutenberg PR 44660] - Legacy Group inner block wrapper should work with constrained layout
* [WordPress/gutenberg#44676 Gutenberg PR 44676] - Hide list items from content area of content locked blocks
* [WordPress/gutenberg#44718 Gutenberg PR 44718] - Margin visualizer: Apply negative value to margins with `calc()`
* [WordPress/gutenberg#44721 Gutenberg PR 44721] - Remove anchor support from the navigation block
* [WordPress/gutenberg#44731 Gutenberg PR 44731] - Buttons: Add specificity for the editor

Follow-up to [54257], [54335], and [54383].

Props bernhard-reiter, czapla, annezazu, cbravobernal, ndiego, bjorsch, nendeb55.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54483


git-svn-id: http://core.svn.wordpress.org/trunk@54042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Oct 11, 2022
Package updates for bug and regression fixes:
@wordpress/block-directory: 3.15.6
@wordpress/block-editor: 10.0.6
@wordpress/block-library: 7.14.6
@wordpress/components: 21.0.5
@wordpress/customize-widgets: 3.14.6
@wordpress/edit-post: 6.14.6
@wordpress/edit-site: 4.14.8
@wordpress/edit-widgets: 4.14.6
@wordpress/editor: 12.16.6
@wordpress/format-library: 3.15.6
@wordpress/interface: 4.16.5
@wordpress/list-reusable-blocks: 3.15.5
@wordpress/nux: 5.15.5
@wordpress/preferences: 2.9.5
@wordpress/reusable-blocks: 3.15.6
@wordpress/server-side-render: 3.15.5
@wordpress/widgets: 2.15.6

References:
* [WordPress/gutenberg#43181 Gutenberg PR 43181] - Merge inner blocks if wrappers are equal
* [WordPress/gutenberg#44098 Gutenberg PR 44098] - Fix content blocks with nested blocks always appear as top level
* [WordPress/gutenberg#44150 Gutenberg PR 44150] - Refresh selection styles
* [WordPress/gutenberg#44415 Gutenberg PR 44415] - Removes `__unstableMaxPages` attribute from Page List and Nav blocks
* [WordPress/gutenberg#44463 Gutenberg PR 44463] - Follow discussion settings in the comments block edit
* [WordPress/gutenberg#44584 Gutenberg PR 44584] - Avoid querying block templates during installation
* [WordPress/gutenberg#44637 Gutenberg PR 44637] - Resizable editor: Fix height setting bug
* [WordPress/gutenberg#44640 Gutenberg PR 44640] - Only include theme.css if the theme declares support for wp-block-styles
* [WordPress/gutenberg#44650 Gutenberg PR 44650] - Fix empty links being created for the author's name comment
* [WordPress/gutenberg#44652 Gutenberg PR 44652] - Block Editor: Fix block search for non-Latin characters
* [WordPress/gutenberg#44660 Gutenberg PR 44660] - Legacy Group inner block wrapper should work with constrained layout
* [WordPress/gutenberg#44676 Gutenberg PR 44676] - Hide list items from content area of content locked blocks
* [WordPress/gutenberg#44718 Gutenberg PR 44718] - Margin visualizer: Apply negative value to margins with `calc()`
* [WordPress/gutenberg#44721 Gutenberg PR 44721] - Remove anchor support from the navigation block
* [WordPress/gutenberg#44731 Gutenberg PR 44731] - Buttons: Add specificity for the editor

Follow-up to [54257], [54335], and [54383].

Props bernhard-reiter, czapla, annezazu, cbravobernal, ndiego, bjorsch, nendeb55.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54483


git-svn-id: https://core.svn.wordpress.org/trunk@54042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Oct 25, 2022
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54687 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 25, 2022
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54687


git-svn-id: http://core.svn.wordpress.org/trunk@54239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Oct 25, 2022
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54687


git-svn-id: https://core.svn.wordpress.org/trunk@54239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
pento pushed a commit to WordPress/wordpress-develop that referenced this pull request Oct 25, 2022
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
Merges [54687] to the 6.1 branch.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/branches/6.1@54688 602fd350-edb4-49c9-b593-d223f7449a82
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 25, 2022
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
Merges [54687] to the 6.1 branch.
See #56467.
Built from https://develop.svn.wordpress.org/branches/6.1@54688


git-svn-id: http://core.svn.wordpress.org/branches/6.1@54240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
@Azragh
Copy link

Azragh commented Oct 28, 2022

This change would actually break the look of all my websites backend developed in the last two years..

Before the update I had one default style declaration which I could overwrite easily with the class .wp-block-button__link:

image

image

After the update I have two default declarations, from which one overwrites my theme styles:

image

image

Is this intended or am I doing something wrong?

ootwch pushed a commit to ootwch/wordpress-develop that referenced this pull request Nov 4, 2022
Package updates for bug and regression fixes:
@wordpress/block-directory: 3.15.6
@wordpress/block-editor: 10.0.6
@wordpress/block-library: 7.14.6
@wordpress/components: 21.0.5
@wordpress/customize-widgets: 3.14.6
@wordpress/edit-post: 6.14.6
@wordpress/edit-site: 4.14.8
@wordpress/edit-widgets: 4.14.6
@wordpress/editor: 12.16.6
@wordpress/format-library: 3.15.6
@wordpress/interface: 4.16.5
@wordpress/list-reusable-blocks: 3.15.5
@wordpress/nux: 5.15.5
@wordpress/preferences: 2.9.5
@wordpress/reusable-blocks: 3.15.6
@wordpress/server-side-render: 3.15.5
@wordpress/widgets: 2.15.6

References:
* [WordPress/gutenberg#43181 Gutenberg PR 43181] - Merge inner blocks if wrappers are equal
* [WordPress/gutenberg#44098 Gutenberg PR 44098] - Fix content blocks with nested blocks always appear as top level
* [WordPress/gutenberg#44150 Gutenberg PR 44150] - Refresh selection styles
* [WordPress/gutenberg#44415 Gutenberg PR 44415] - Removes `__unstableMaxPages` attribute from Page List and Nav blocks
* [WordPress/gutenberg#44463 Gutenberg PR 44463] - Follow discussion settings in the comments block edit
* [WordPress/gutenberg#44584 Gutenberg PR 44584] - Avoid querying block templates during installation
* [WordPress/gutenberg#44637 Gutenberg PR 44637] - Resizable editor: Fix height setting bug
* [WordPress/gutenberg#44640 Gutenberg PR 44640] - Only include theme.css if the theme declares support for wp-block-styles
* [WordPress/gutenberg#44650 Gutenberg PR 44650] - Fix empty links being created for the author's name comment
* [WordPress/gutenberg#44652 Gutenberg PR 44652] - Block Editor: Fix block search for non-Latin characters
* [WordPress/gutenberg#44660 Gutenberg PR 44660] - Legacy Group inner block wrapper should work with constrained layout
* [WordPress/gutenberg#44676 Gutenberg PR 44676] - Hide list items from content area of content locked blocks
* [WordPress/gutenberg#44718 Gutenberg PR 44718] - Margin visualizer: Apply negative value to margins with `calc()`
* [WordPress/gutenberg#44721 Gutenberg PR 44721] - Remove anchor support from the navigation block
* [WordPress/gutenberg#44731 Gutenberg PR 44731] - Buttons: Add specificity for the editor

Follow-up to [54257], [54335], and [54383].

Props bernhard-reiter, czapla, annezazu, cbravobernal, ndiego, bjorsch, nendeb55.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54483 602fd350-edb4-49c9-b593-d223f7449a82
ootwch pushed a commit to ootwch/wordpress-develop that referenced this pull request Nov 4, 2022
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
See #56467.

git-svn-id: https://develop.svn.wordpress.org/trunk@54687 602fd350-edb4-49c9-b593-d223f7449a82
@scruffian
Copy link
Contributor Author

If you're targeting .wp-block-button__link in your theme then when the CSS is loaded in the editor it should be wrapped with the .editor-styles-wrapper class, so it should have the same specificity as the default styles.

@Azragh
Copy link

Azragh commented Nov 15, 2022

@scruffian If you're looking at my last screenshot you can see that the class is present. The big ruleset in the middle is coming from my theme. The one above (which overrides my styles) came with this update. The one below was there since ever (except the new ".wp-element-button" class).

I load the block librarys CSS, so why do I get this "classic.css" file with only one declaration which is already present at all?

In the meantime I found out that I can dequeue "classic.css" from frontend, but this sadly doesn't work in the admin area cause it's inline there. Any advice to get rid of it?

VenusPR added a commit to VenusPR/Wordpress_Richard that referenced this pull request Mar 9, 2023
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54687


git-svn-id: http://core.svn.wordpress.org/trunk@54239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
VenusPR added a commit to VenusPR/Wordpress_Richard that referenced this pull request Mar 9, 2023
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
Merges [54687] to the 6.1 branch.
See #56467.
Built from https://develop.svn.wordpress.org/branches/6.1@54688


git-svn-id: http://core.svn.wordpress.org/branches/6.1@54240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Firefishy pushed a commit to osmfoundation/osmblog-wp-theme that referenced this pull request Aug 23, 2023
In [54358], styling for Button blocks that had been removed from classic themes was reintroduced. However, it was added with a global scope, whereas editor styles are usually added with a `.editor-styles-wrapper` selector, which makes them more specific.

This change modifies the way that classic theme styles are added so that they also get wrapped in an `.editor-styles-wrapper` selector to match specificity.

Furthermore, adjust specificity for some Button block related styling in the editor for the Twenty Twelve and Twenty Twenty themes.

Merges [WordPress/gutenberg#44731 Gutenberg PR 44731] into trunk.

Follow-up to [54358].
Props scruffian, cbravobernal, sabernhardt, audrasjb.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54687


git-svn-id: http://core.svn.wordpress.org/trunk@54239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Buttons Affects the Buttons Block [Type] Bug An existing feature does not function as intended
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

4 participants