Skip to content

Link and :hover styles in Navigation block being overridden by core block styles #62987

@bgardner

Description

@bgardner

Description

Likely a symptom similar to discussion at Core block styles are overriding theme.json styles in WordPress 6.6, the link and :hover styles for the Navigation block are being overridden by core block styles. This is a concerning trend, as this overriding is also happening at #62960 in addition to other blocks that have yet to be fixed (#62679 (comment)).

Here is the code from /wp-includes/blocks/navigation/style.min.css?ver=6.6-RC1 that is causing the override:

.wp-block-navigation .wp-block-navigation-item__content.wp-block-navigation-item__content {
	color: inherit;
}

Here is the code it is overriding:

:root :where(.wp-block-navigation a:where(:not(.wp-element-button))) {
	color: var(--wp--preset--color--contrast);
}

Here is the code I have in the theme.json file seen below in the video

{
	"styles": {
		"blocks": {
			"core/navigation": {
				"elements": {
					"link": {
						"color": {
							"text": "var(--wp--preset--color--contrast)"
						},
						":hover": {
							"color": {
								"text": "var(--wp--preset--color--primary)"
							}
						}
					}
				}
			}
		}
	}
}

Step-by-step reproduction instructions

  1. Add code above into theme.json file.
  2. Hover links in Navigation block on front end.
  3. Witness theme.json style being overridden by core block style.

Screenshots, screen recording, code snippet

Screen.Recording.2024-06-28.at.9.09.52.PM.mp4

Environment info

WordPress 6.6 RC1

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

Metadata

Metadata

Assignees

Labels

[Block] NavigationAffects the Navigation Block[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions