Skip to content

Block Supports: Show block style variation colors over a block type text gradient - #15366

Open
aaronrobertshaw wants to merge 3 commits into
WordPress:trunkfrom
aaronrobertshaw:backport/86164-variation-text-clip
Open

aaronrobertshaw wants to merge 3 commits into
WordPress:trunkfrom
aaronrobertshaw:backport/86164-variation-text-clip

Conversation

@aaronrobertshaw

@aaronrobertshaw aaronrobertshaw commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Backport of Gutenberg PR WordPress/gutenberg#86164

Trac ticket: https://core.trac.wordpress.org/ticket/66438

Fixes a block style variation text color being hidden when the block type sets a text gradient. Reported in WordPress/gutenberg#84599.

This PR backports:

  • the private text_clip_base_blocks option for WP_Theme_JSON::get_stylesheet(),
  • the text clip escape in the variation's main, breakpoint and pseudo-state rules,
  • passing the merged block type styles from wp_render_block_style_variation_support_styles(),
  • and the accompanying block style variation and WP_Theme_JSON tests.

The editor side of the fix arrives later with the Gutenberg package update.

Overlap: #15432 changes the same block style variation rules in WP_Theme_JSON::get_styles_for_block(), so whichever of the two merges second needs a small rebase that keeps $text_clip_base_block_styles in the variation and breakpoint text clip bases. #15433 touches nearby lines in class-wp-theme-json.php but merges cleanly with this PR.

Testing instructions

Note

Only the front end is fixed in this PR. The editor still shows the gradient until the Gutenberg package update. Check the front end.

  1. Activate a block theme.
  2. Add this to a plugin or functions.php:
register_block_style( 'core/paragraph', array(
	'name'       => 'green-text',
	'label'      => 'Green text',
	'style_data' => array( 'color' => array( 'text' => '#00aa00' ) ),
) );
add_filter( 'wp_theme_json_data_theme', function ( $theme_json ) {
	return $theme_json->update_with( array(
		'version' => 3,
		'styles'  => array( 'blocks' => array( 'core/paragraph' => array(
			'background' => array(
				'gradient'       => 'linear-gradient(90deg, #ff0000 0%, #0000ff 100%)',
				'backgroundClip' => 'text',
			),
		) ) ),
	) );
} );
  1. Add a Paragraph to a post, select the Green text style and publish it. The editor canvas still shows the gradient, which is expected.
  2. View the post. The paragraph text should be solid green, not the red to blue gradient.
  3. Inspect the block-style-variation-styles-inline-css style tag. It should contain a rule like this (the number suffix can differ):
:root :where(p.is-style-green-text--1){color: #00aa00;-webkit-text-fill-color: currentColor;}

On trunk the rule has no -webkit-text-fill-color, and the gradient still paints the letters.

Use of AI

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: The mechanical port, tests and this description.

@aaronrobertshaw aaronrobertshaw self-assigned this Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

…ext gradient.

When a block type sets a text gradient (a background gradient clipped to the text), a block style variation's text color was hidden behind it. The variation's instance stylesheet is built from the variation alone, so it could not see the block type's text clip to escape it.

Pass the merged block type styles to the instance stylesheet through a private `text_clip_base_blocks` option, and use them to escape the text clip in the variation's main, breakpoint and pseudo-state rules.

Synced from WordPress/gutenberg#86164.
…t clip base.

A block pseudo node, such as `:hover`, lists the block's style variations too. The variation rule it re-emits used the pseudo styles as its text clip base, so a clip set only in `:hover` added escapes to the variation's resting rule. Read the block's own styles instead.

Drops the instance box clip test, which the text clip helper tests already cover, and adds a `WP_Theme_JSON` regression test for the pseudo node case.

Synced from WordPress/gutenberg#86164.
@aaronrobertshaw
aaronrobertshaw force-pushed the backport/86164-variation-text-clip branch from bb64b43 to 95c0208 Compare November 4, 2026 03:54
@aaronrobertshaw
aaronrobertshaw requested review from andrewserong and ramonjd and removed request for ramonjd November 4, 2026 12:57
@aaronrobertshaw

Copy link
Copy Markdown
Contributor Author

This should be ready for review.

One thing to note: #15432 changes the same variation rules, so whichever lands second needs a small rebase.

@aaronrobertshaw
aaronrobertshaw marked this pull request as ready for review November 4, 2026 12:58
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

Core Committers: Use this line as a base for the props when committing in SVN:

Props aaronrobertshaw.

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@ramonjd ramonjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared PR with Gutenberg #86164 === matches.

wp_ prefixes / @ticket 66438 annotations / tests pass for me locally too

Thanks!

Two notes:

  • Assuming this should land before #15432. At the very least it keeps the Gutenberg merge order, and #15432 then adds $text_clip_base_block_styles back to its two variation base lists.
  • We should wait until trunk opens for 7.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants