-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: Fix complex variation selectors when using selectors API #7825
Theme.json: Fix complex variation selectors when using selectors API #7825
Conversation
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 Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked that the synced changes match https://github.com/WordPress/wordpress-develop/pull/7825/files
I also ran through the tests again. Things work as expected on the frontend.
![Screenshot 2024-11-21 at 10 45 51 am](https://private-user-images.githubusercontent.com/6458278/388300361-901ed11a-cedd-4318-8aa6-06aeab0ae8e3.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MzI0MDMsIm5iZiI6MTczOTQzMjEwMywicGF0aCI6Ii82NDU4Mjc4LzM4ODMwMDM2MS05MDFlZDExYS1jZWRkLTQzMTgtOGFhNi0wNmFlYWIwYWU4ZTMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMDczNTAzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTJkNWVlNTVkZDhhMTNmZjlhMWUxZjAwNTMzMTNhZmU2MDc5MTg1YzhiOGE0ZDlmYWU0NWE0NDg2NzQ0NGU1MiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.n5cEYfqpNiloY58uDUwBade8uVJjpd2npDpkDRH2bmc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thanks for adding tests for this!
This PR backports the PHP changes from WordPress/gutenberg#67061
The old approach to converting a block's CSS selectors for block style variations was fairly simplistic. It worked when a block used a simple class based selector however as blocks evolve and the Selectors API is used more, it needs to handle more complex selectors such as the List block's .wp-block-list:not(.wp-block-list .wp-block-list).
The changes in the linked Gutenberg PR prevent generation of malformed block style variation selectors when a block's selector leverages a CSS function such as :not() or chains multiple classes e.g. .wp-block-list.my-custom-class.
Trac ticket: https://core.trac.wordpress.org/ticket/62471
Test Instructions
npm run test:php -- --filter Tests_Theme_wpThemeJson
__experimentalSelector
property in block.jsonScreenshots
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.