-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Multiple blocks: Add missing has-link-color class to the front #47357
Conversation
@ockham Hi! I know you are very busy but can you confirm if it is not possible to add the has-link-color class with the style engine? I could not figure it out and make it work. Or, do you know who I can ping? I believe adding the class directly like this through get_block_wrapper_attributes is what we were trying to avoid. |
I could only find one block that uses |
Hey @carolinan! I don't really know myself how to do that, but maybe Style Engine experts @andrewserong, @ramonjd, or @scruffian could help? 😊 |
It's a little tricky this one, but I think the current shape of the style engine support doesn't quite cover link color (or elements) directly. The main functionality we currently have is either simple direct style values (like spacing properties, typography, etc), or for the more complex block supports (elements, layout) then the block support is responsible for passing values to the style engine and then the block support does its own parsing / output / working out where to put things. So, for link color, from the perspective of the style engine, it doesn't really exist. Within What does that mean for how we could approach this problem? At first glance, I think maybe the Elements block support (in There is a caveat here, though: classnames for elements are currently being injected via So, I think for now, I'd probably go with the manual approach of passing down the classnames as you've done here, then once the tag processor is ready to be used again, look at centralising the injecting of the classname within What do you think? |
Thank you for the detailed reply. |
Flaky tests detected in 6e5bf891c6580beb1a971b3cebd1c02b7a7c42f2. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3994415609
|
008771f
to
30771d9
Compare
What?
Adds the
has-link-color
class to the front of several dynamic blocks when a link color is chosen.Closes #47233
Why?
The class is present in the editor but not on the front.
This is an edge case:
Why these blocks? Because they showed up as problematic when testing 56487. There may be more dynamic blocks affected that have not been tested yet.
How?
This PR manually adds the has-link-color class through
get_block_wrapper_attributes
in index.php.Testing Instructions
You can test this in any block theme with support for link colors.
The post comments link can only be added in the site editor.
Open the site editor and add a query loop block with a post comments link block inside the post template:
or use this sample code:
Post blocks:
Sample query loop code:
Various blocks:
Set a link color: it does not matter if it is a preset or custom color.
Save and view the front. Confirm that the link color is still working and that the class name
has-link-color
is now added to the wrapper.