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 -Adding color to the search block changes the wrong element #34216

Closed
2 tasks done
carolinan opened this issue Aug 22, 2021 · 2 comments
Closed
2 tasks done
Labels
[Block] Search Affects the Search Block - used to display a search field Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json

Comments

@carolinan
Copy link
Contributor

carolinan commented Aug 22, 2021

Description

In the editor, the color options for the search block changes the submit button in the form.
But when you add colors using theme.json, the colors are added to the form element.

In addition, the color contrast warning is always visible in the editor no matter what colors are selected.

Step-by-step reproduction instructions

  1. Add a theme.json with colors for the search block to your test theme. (Example code below)
  2. In either editor, add a search block.
  3. See that the colors of the block are affecting the form, not the button in the block.
  4. View the front and see the same result.

Screenshots, screen recording, code snippet

Theme.json:

{
	"version": 1,
	"styles": {
		"blocks": {
			"core/search": {
				"color": {
					"background": "var(--wp--preset--color--black)"
				}
			}
		}
	}
}

CSS output:

.wp-block-search {
    background-color: var(--wp--preset--color--black);
}

Screenshot:
The black background is visible on the form element in the search block in the editor

Environment info

WordPress 5.8
Gutenberg 11.3.0

Pre-checks

  • I have searched the existing issues.
  • I have tested with all plugins deactivated except Gutenberg.
@carolinan carolinan added [Block] Search Affects the Search Block - used to display a search field Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Aug 22, 2021
@stacimc
Copy link
Contributor

stacimc commented Aug 24, 2021

By default the style will be applied at the top level, to the containing div of the block. The color block support for the Search block is using __experimentalSkipSerialization to apply the user-selected styles to the inner button instead.

The issue is that currently there's no way to specify in theme.json to target an inner element instead of the block wrapper (without affecting all block supports for that block). Linking some ongoing discussions about how this should be handled:

@carolinan
Copy link
Contributor Author

carolinan commented Jun 22, 2022

I will retest this tomorrow, this was solved by adding buttons to theme.json elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Search Affects the Search Block - used to display a search field Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json
Projects
None yet
Development

No branches or pull requests

2 participants