Add 'wp-block-button__link' to the link selector's ':not' collection#42242
Closed
pbking wants to merge 1 commit into
Closed
Add 'wp-block-button__link' to the link selector's ':not' collection#42242pbking wants to merge 1 commit into
pbking wants to merge 1 commit into
Conversation
matiasbenedetto
approved these changes
Jul 8, 2022
matiasbenedetto
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the context in the PR description.
With this change, both legacy and new buttons and links work as expected. LGTM
Contributor
Author
|
Looks like some unit tests need to change for this to pass. |
aristath
reviewed
Jul 18, 2022
| */ | ||
| const ELEMENTS = array( | ||
| 'link' => 'a:not(.wp-element-button)', | ||
| 'link' => 'a:not(.wp-element-button, .wp-block-button__link)', |
Member
There was a problem hiding this comment.
Shouldn't this be like this instead? 🤔
Suggested change
| 'link' => 'a:not(.wp-element-button, .wp-block-button__link)', | |
| 'link' => 'a:not(.wp-element-button):not(.wp-block-button__link)', |
Contributor
Author
|
This seems to have been addressed by this change in a simpler/better way. Closing this in preference to that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Add
wp-block-button__linkto the link selector's:notcollectionWhy?
In #40260 the
.wp-element-buttonclass was introduced and link element styles were applied to allaanchor elements but excluded those with that class.However the class is only introduced on new content (or when old content is re-serialized). So any Button Blocks created prior to that change have the link styles applied.
Expected:

Before:


After:


How?
This adds the
.wp-block-button__linkto the anchor selector excluding any button that has that class from the anchor styles.Testing Instructions
Load a site that has content created prior to the #40260 change. (I imported the content from this site and used this page).
Configure your theme with a link color via theme.json :
Note that before this change the button block is rendered with the color assigned to the link element.
Apply the change and note that the button block is no longer rendered with the color assigned to the link element.