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

Image block style - .is-style-rounded overrides my block style css #35151

Closed
romerocs opened this issue Sep 27, 2021 · 2 comments
Closed

Image block style - .is-style-rounded overrides my block style css #35151

romerocs opened this issue Sep 27, 2021 · 2 comments
Labels
[Block] Image Affects the Image Block CSS Styling Related to editor and front end styles, CSS-specific issues.

Comments

@romerocs
Copy link

Description

I've created a custom block style for applying rounded corners to block images. However, after a recent WP core update I noticed my block styles were being overridden by the core block library css. It resets the border-radius for all block images to border-radius: inherit. So now I need to increase the specificity of my css in order to apply my styles. The high specificity of this css makes it difficult to apply custom styles and sets a precedent where I'm worried my custom styles will be overridden by a core update.

Is there a reason why the block image css wasn't simply written as .wp-block-image img { border-radius: inherit; }?

block-library/style.min.css

.wp-block-image:not(.is-style-rounded) img {
 border-radius:inherit
}

custom-block-styles.css

.is-style-custom-rounded-corners img {
  border-radius: #{$_border_radius};
}

PS, we use the rounded corner style on the site so removing it isn't an option.

Step-by-step reproduction instructions

  1. Create a custom block style for adding rounded corners
  2. Apply the custom block style to an image
  3. The custom block style may not work depending on its level of specificity (see description)

Screenshots, screen recording, code snippet

No response

Environment info

  • Wordpress 5.8.1

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

No

@carolinan carolinan added the [Block] Image Affects the Image Block label Sep 28, 2021
@skorasaurus skorasaurus added the CSS Styling Related to editor and front end styles, CSS-specific issues. label Sep 28, 2021
@markhowellsmead
Copy link

The :not() selector is being used in many places in core, which has a comparatively high specificity and is therefore increasingly difficult to override. The use of this technique needs to be reviewed by whomever (or by the team) is “in charge” of Core/Editor CSS.

See also #36135, #35840, #34047, #29705, #17511.

@aaronrobertshaw
Copy link
Contributor

This issue has been resolved via #31366, which leverages new feature level selectors for block supports to target the inner img. This meant the problematic style wasn't required anymore and was subsequently removed.

I'll close this issue now however if you have any further concerns or questions, please let me know.

Is there a reason why the block image css wasn't simply written as .wp-block-image img { border-radius: inherit; }?

I believe this was because the suggested selector wouldn't allow custom border radii set by end users to take precedence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block CSS Styling Related to editor and front end styles, CSS-specific issues.
Projects
None yet
Development

No branches or pull requests

5 participants