Skip to content

Theme.json -Adding color to the search block changes the wrong element #34216

@carolinan

Description

@carolinan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Block] SearchAffects the Search Block - used to display a search field

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions