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: Incorrect selectors are used when color palettes are added to blocks #31660

Closed
carolinan opened this issue May 10, 2021 · 6 comments · Fixed by #32190 or #33951
Closed

Theme.json: Incorrect selectors are used when color palettes are added to blocks #31660

carolinan opened this issue May 10, 2021 · 6 comments · Fixed by #32190 or #33951
Assignees
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended

Comments

@carolinan
Copy link
Contributor

carolinan commented May 10, 2021

Description

When adding a color palette to a block in theme.json, the incorrect selectors are used
and the color is applied incorrectly.

When I add the following to theme.json, all headings have a medium blue background color:

{
	"version": 1,
	"settings": {
		"blocks": {
			"core/heading": {
				"color": {
					"palette": [
						{
							"slug": "white",
							"color": "#fff",
							"name": "White"
						},
						{
							"slug": "medium-blue",
							"color": "#00A0D2",
							"name": "Medium blue"
						}
					]
				}
			}
		}
	}
}

Results in the following CSS:

h1, h2, h3, h4, h5, h6.has-medium-blue-border-color {
    border-color: #00A0D2 !important;
}

h1, h2, h3, h4, h5, h6.has-medium-blue-background-color {
    background-color: #00A0D2 !important;
}

h1, h2, h3, h4, h5, h6.has-medium-blue-color {
    color: #00A0D2 !important;
}

Step-by-step reproduction instructions

Please list the steps needed to reproduce the bug. For example:

  1. Add the theme.json code above to an fse theme, for example emptytheme.
  2. View a page with different type headings, in the editor and front.
  3. See the bug.

Expected behaviour

The color should only be applied ...when it is applied.

Actual behaviour

Example:
The .has-medium-blue-background-color is only used with the h6 heading, all other headings have a blue background by default.

WordPress information

  • WordPress version: 5.7.1
  • Gutenberg version: current trunk
  • Are all plugins except Gutenberg deactivated? yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? empty theme

Device information

  • Device: Desktop
  • Operating system: Windows 10
  • Browser: Chrome Version 90.0.4430.93
@carolinan carolinan 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 10, 2021
@oandregal oandregal mentioned this issue May 25, 2021
82 tasks
@oandregal
Copy link
Member

Thanks for sharing, Carolina, I'm looking into this one.

@oandregal oandregal self-assigned this May 25, 2021
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label May 25, 2021
@oandregal
Copy link
Member

Got a fix at #32190

@carolinan
Copy link
Contributor Author

This bug is back when I use WP 5.8 and Gutenberg 11.1, but only in the site editor.

.editor-styles-wrapper h1, .editor-styles-wrapper h2, .editor-styles-wrapper h3, .editor-styles-wrapper h4, .editor-styles-wrapper h5, .editor-styles-wrapper h6.has-medium-blue-border-color {
    border-color: var(--wp--preset--color--medium-blue) !important;
}

.editor-styles-wrapper h1, .editor-styles-wrapper h2, .editor-styles-wrapper h3, .editor-styles-wrapper h4, .editor-styles-wrapper h5, .editor-styles-wrapper h6.has-medium-blue-background-color {
    background-color: var(--wp--preset--color--medium-blue) !important;
}

.editor-styles-wrapper h1, .editor-styles-wrapper h2, .editor-styles-wrapper h3, .editor-styles-wrapper h4, .editor-styles-wrapper h5, .editor-styles-wrapper h6.has-medium-blue-color {
    color: var(--wp--preset--color--medium-blue) !important;
}

@carolinan carolinan reopened this Jul 30, 2021
@oandregal
Copy link
Member

I'm looking into this.

@oandregal
Copy link
Member

Prepared #33951 to fix this (ongoing).

@oandregal
Copy link
Member

#33951 is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Status] In Progress Tracking issues with work in progress [Type] Bug An existing feature does not function as intended
Projects
None yet
2 participants