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

theme.json: Global link color always overloads any block styles on the frontend #31990

Closed
fklein-lu opened this issue May 19, 2021 · 2 comments
Closed
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended

Comments

@fklein-lu
Copy link
Contributor

Description

When declaring a link color under style:elements and a link color under style:blocks, the global color always overrides the block specific selection.

Step-by-step reproduction instructions

  1. Open TT1 and add the following to the theme.json:
{
	"version": 1,
	"styles": {
		"elements": {
			"link": {
				"color": {
					"text": "pink"
				}
			}
		},
		"blocks": {
			"core/site-title": {
				"elements": {
					"link": {
						"color": {
							"text": "red"
						}
					}
				}
			}
		}
	}
}
  1. See on the frontend that the site title is pink.

Expected behaviour

Blocks should be able to override the global link color.

Actual behaviour

In the admin, the site title is red, and other links pink, as expected:

link-admin

On the frontend however, the site title is always pink.

link-frontend

Screenshots or screen recording

CSS on the backend:

link-css-backend

The grey background is from #30874.

CSS on the frontend:

link-css

WordPress information

  • WordPress version: 5.7.2
  • Gutenberg version: 10.6.2
  • Are all plugins except Gutenberg deactivated? Yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? TT1

Device information

  • Device: Mac
  • Operating system: MacOS
  • Browser: Chrome
@skorasaurus skorasaurus added Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended labels May 20, 2021
@skorasaurus skorasaurus added the CSS Styling Related to editor and front end styles, CSS-specific issues. label Jun 28, 2021
@oandregal
Copy link
Member

👋 I can't repro this. I'm using: WordPress 5.7.2, Gutenberg 11.0.0, and tried with TT1 and TT1-blocks. Both work as expected.

By adding the theme.json in the issue description to TT1 I get the following CSS in the front-end (plus all the CSS for preset classes and CSS custom properties):

a {
  color: pink;
}
.wp-block-site-title a {
  color: red;
}

This is correct. However, it does nothing because the TT1 is not prepared to work with that: it doesn't use the site title block (so no wp-block-site-title class to target) and the specificity it has for links in its own stylesheet is higher than a.

@fklein-lu I wonder if the bug is no longer reproducible due to latest changes or if you had a different setup?

@getsource
Copy link
Member

getsource commented Aug 31, 2021

Hi @fklein-lu !

This issue was tested in a triage session today.

A few of us tested with varying themes, and as @oandregal mentioned previously, were unable to reproduce it.

I suspect that this might have been fixed since the original posting.
As such, I'm going to close the issue for now, but if you're still having the issue, please feel free to re-open!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

4 participants