Skip to content

Core/File: Reduce specificity of pseudo-selector styles for better override support via theme.json #70358

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

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

yogeshbhutkar
Copy link
Contributor

@yogeshbhutkar yogeshbhutkar commented Jun 9, 2025

What?

Closes #70342

This PR lowers the specificity of pseudo-selector styles within the .wp-block-file__button class to 0,1,0, allowing them to be more easily overridden via theme.json.

Why?

Previously, the :visited and :hover pseudo-selectors on file block buttons could not be overridden using theme.json due to higher specificity.

How?

Replacing &:is(a) with &:where(a) preserved the styles while reducing specificity from 0,1,1 to 0,1,0.

Testing Instructions

  1. Create a new post.
  2. Add a file block.
  3. Attach a file to it.
  4. Use the following code and paste it under the styles key within theme.json.
Code
"core/file": {
  "elements": {
	"button": {
		":hover": {
			"color": {
				"text": "#d34949"
			}
		},
		":visited": {
			"color": {
				"text": "#49d353"
			}
		}
	}
  }
}
  1. Confirm that the hover and visited styles are properly applied on the front-end.

Testing Instructions for Keyboard

Same.

Screenshots or screencast

Before After
before after
before after

@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review June 9, 2025 06:14
Copy link

github-actions bot commented Jun 9, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @EldarAgalarov.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: EldarAgalarov.

Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: Mukulsingh27 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Block] File Affects the File Block Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] File Affects the File Block 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

core/file: Cannot override styles via theme.json
2 participants