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

Fix: Incorrect selector generated by append_to_selector method #48759

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

t-hamano
Copy link
Contributor

@t-hamano t-hamano commented Mar 5, 2023

Fixes: #48393
Fixes: #48706

Related to: #47833

What?

This PR fixes the problem that the append_to_selector() method of the WP_Theme_JSON_Gutenberg class does not generate the correct selector.

Why?

In #47833, a process has been added to check if the selector contains a comma to avoid unwanted implide/explode. However, the parameters of the str_contains function to check for it appears to be reversed.

Testing Instructions

Confirm that the correct selector is generated in the two issues that this PR fixes.

Testing for #48393 (Button Block: Style for pseudo-elements has priority)

The pseudo-element selector should be correctly generated and the background color of the button should change to the expected color.

Before

before_button

After

after_button

Testing for #48706 (Heading in selectors aren't set correctly at the block level)

  • Enable EmptyTheme and overwrite theme.json with the code described in this comment.
  • Insert a group block in the post.
  • Confirm that the global inline style is outputting the correct selector.

Before

before_group

After

after_group

@t-hamano t-hamano force-pushed the fix/incorrect-style-selector branch from e518e06 to e08279b Compare March 5, 2023 13:15
@t-hamano t-hamano added [Type] Performance Related to performance efforts [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Mar 5, 2023
@t-hamano t-hamano marked this pull request as ready for review March 5, 2023 13:18
@t-hamano
Copy link
Contributor Author

t-hamano commented Mar 5, 2023

I believe this PR would change the performance measurements reported in this comment, but I wasn't sure how to test it. I would appreciate it if you could perform the performance measurement again 🙏

@t-hamano t-hamano self-assigned this Mar 5, 2023
@github-actions
Copy link

github-actions bot commented Mar 5, 2023

Flaky tests detected in e08279b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4336234328
📝 Reported issues:

@oandregal
Copy link
Member

Backporting as of WordPress/wordpress-develop#4412

@felixarntz
Copy link
Member

@oandregal I suggest we wait for this until #50266 to backport? Or is there any rush in backporting this now?

@oandregal
Copy link
Member

It's fine to wait. I just wanted to have this linked somewhere. As a general practice, but also, we don't forget the proper attribution to t-hamano: see WordPress/wordpress-develop#4412 (comment) :)

@spacedmonkey
Copy link
Member

@spacedmonkey spacedmonkey removed the Needs PHP backport Needs PHP backport to Core label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Type] Performance Related to performance efforts
Projects
None yet
4 participants