Skip to content

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

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

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.

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.

…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 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.

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.

1 participant