Repository navigation
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +179 B (0%) Total Size: 7.93 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in 8baf8cf. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25777436528
|
Good catch, I'll address that. There's also a bit of subtlety that |
3cd0aa2 to
8baf8cf
Compare
|
|
||
| $compiled = wp_style_engine_get_styles( $style[ $state ] ); | ||
| $compiled = wp_style_engine_get_styles( | ||
| gutenberg_normalize_state_style_for_css_output( $style[ $state ] ) |
There was a problem hiding this comment.
I thought the style engine already dealt with conversion from preset strings to css variables, so this shouldn't be needed?
There was a problem hiding this comment.
Looks like not for some of the border rules:
gutenberg/packages/style-engine/src/class-wp-style-engine.php
Lines 131 to 141 in cb74beb
There needs to be a css_vars property for it to generate the css vars.
I'm not sure if the vars could be added there, I'm not particularly familiar with it.
There was a problem hiding this comment.
This is what codex said about the risks of adding the css_vars property:
Possible adverse effects
The main risk is that this is broader than pseudo states.
Any PHP path using the style engine with a preset top-level border color would start emitting an inline border-color: var(...) declaration in addition to border color classnames.
That could affect:
- block support frontend output from lib/block-supports/border.php
- tests expecting preset border colors to be represented only as classes
- markup/style output size
- cascade behavior, because inline border-color can outrank stylesheet class rules
The cascade behavior is the biggest concern. Existing behavior for preset border color seems intentionally class-based for top-level border.color, likely matching other preset class workflows. Adding css_vars would make preset border colors behave more like inline custom colors in some PHP-rendered contexts.
There was a problem hiding this comment.
Yeah outputting extra inline styles doesn't sound good. Oh well I suppose we can live with a little code duplication 😅
| '.wp-block-test:hover { border-top-color: #0000ff !important; }\n.wp-block-test:hover { border-top-style: solid; }' | ||
| ); | ||
| } ); | ||
| } ); |
There was a problem hiding this comment.
I wonder how much value these tests will be. Is it likely the !importants will regress unless someone removes them deliberately?
* Fix border styles for block instance pseudo states * Try adding !important to authored border-style rules * Revise/simplify PHP border fallback to inject declarations * Revert editor fallback border style changes for pseudo states * Compile border style fallbacks seperately to avoid setting !important * Add missing !important properties * Use existing cleanEmptyObject util * Update outdated comment
* first try to create states supports * added tests and fixed css specificity and selectors * refactor to use selectors instead of a new experimental attribute * added unit tests * add toggle to show the changes on canvas * fix linting * fixed dependencies * add the rest of the panels to the states * use the proper panels for the non default states * fix reset filter and added tests * add spacing to toggle * Simplify HTML processor logic in states block support Replace the $found flag and double WP_HTML_Tag_Processor instantiation with a single processor using if/elseif branching. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactored props and BlocksStatesControl * extract shared hook for block states * Remove internal SlotFills from private-apis * Add useBlockStyle( path, state ) hook for block instance style reads/writes * Use useBlockStyle in DimensionsPanel, replacing useBlockStateProps * Use useBlockStyle in BackgroundImagePanel, replacing useBlockStateProps * Use useBlockStyle in BorderPanel and TypographyPanel, replacing useBlockStateProps * Fix useBlockStyle to use updateBlockAttributes instead of setAttributes from context * Remove useBlockStateProps now that all panel hooks use useBlockStyle * Use Symbol key for BlockInspectorPreTabs slot/fill to keep it internal * Rename __experimentalStates support key to states * fix the other slotFill * Use buildStateResetAllFilter in BackgroundInspectorControl * Add tests for useBlockStyle hook * fix test failures * added block.json schema * Use style engine store for states block support CSS output, matching layout.php and position.php * use important only in the cases that need it * Update state support to use config instead of block supports (#78088) * Block Editor: Use config for block pseudo states * Block supports: Render pseudo states from config * Block Editor: Support nested block style state paths * Scope block support reset all to selected style state and remove useBlockStyle hook. (#78141) Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> * Show block instance state badges (#78142) * Show block state badges in inspector * Move state control badges to separate component * Render state badges from global styles header * Derive active states in state badges * Use useToolsPanelDropdownMenuProps for block instance state control menu * Fix duplicate import * Show pseudo state global styles on canvas when "Show state on canvas" is active (#78190) * Show global styles on the canvas for pseudo states when Show state on canvas is active * Use existing merge helper * Improve accuracy of useMemo deps * Fix border styles for block instance pseudo states (#78195) * Fix border styles for block instance pseudo states * Try adding !important to authored border-style rules * Revise/simplify PHP border fallback to inject declarations * Revert editor fallback border style changes for pseudo states * Compile border style fallbacks seperately to avoid setting !important * Add missing !important properties * Use existing cleanEmptyObject util * Update outdated comment * Avoid using symbol key for BlockCardControls since it is never exported * add core changelog * Revert "Avoid using symbol key for BlockCardControls since it is never exported" This reverts commit 9f4e1fe. --------- Unlinked contributors: onetrev, davewhitley, itsdavidmorgan, le-sgs. Co-authored-by: MaggieCabrera <onemaggie@git.wordpress.org> Co-authored-by: scruffian <scruffian@git.wordpress.org> Co-authored-by: talldan <talldanwp@git.wordpress.org> Co-authored-by: tellthemachines <isabel_brison@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org> Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org> Co-authored-by: andrewserong <andrewserong@git.wordpress.org> Co-authored-by: paaljoachim <paaljoachim@git.wordpress.org> Co-authored-by: HILAYTRIVEDI <hilayt24@git.wordpress.org> Co-authored-by: javierarce <javiarce@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org> Co-authored-by: mtias <matveb@git.wordpress.org> Co-authored-by: carolinan <poena@git.wordpress.org> Co-authored-by: eric-michel <ytfeldrawkcab@git.wordpress.org> Co-authored-by: cbirdsong <cbirdsong@git.wordpress.org> Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: shaunandrews <shaunandrews@git.wordpress.org> Co-authored-by: nathanrodrigues2111 <nathanrbsf@git.wordpress.org> Co-authored-by: masteradhoc <masteradhoc@git.wordpress.org> Co-authored-by: deryckoe <deryck@git.wordpress.org> Co-authored-by: draganescu <andraganescu@git.wordpress.org> Co-authored-by: jarekmorawski <jarekmorawski@git.wordpress.org> Co-authored-by: simonwammerfors <simonwammerfors@git.wordpress.org> Co-authored-by: mateuswetah <tainacan@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: colinduwe <colind@git.wordpress.org> Co-authored-by: matiasbenedetto <mmaattiiaass@git.wordpress.org> Co-authored-by: hanneslsm <hanneslsm@git.wordpress.org> Co-authored-by: JiveDig <jivedig@git.wordpress.org> Co-authored-by: Bovelett <annebovelett@git.wordpress.org> Co-authored-by: hadamlenz <adrock42@git.wordpress.org> Co-authored-by: ethanclevenger91 <eclev91@git.wordpress.org> Co-authored-by: getdave <get_dave@git.wordpress.org>

What?
Based on #76491 and proposes to merge into that branch.
If a user tries setting a border style for 'Hover' / 'Focus' and other pseudo states on a block instance, the style usually won't work both in the editor. This PR fixes the issue.
Why?
Usually when a user sets
border-widthorborder-colorfor a block, there are some fallback styles that automatically setborder-style: solidtoo. This is usually done via a style like this:But note this only solves for inline styles. Pseudo states generate style sheets. A different solution is needed.
Separately on the frontend, there's also an issue with the color presets, which are usually added as classnames. That also won't work for pseudo styles.
How?
This PR uses a similar solution that's present elsewhere in the codebase, it adds in a style property for
border-style: solidso that generated styles also include it. A similar solution is used on the frontend/PHP.While I did search for existing utils, the only one I found that seemed like a good fit is for the global styles blocks UI (screen-block.tsx), so a shared helper has been extracted to be used both by pseudo states and global styles. Let me know if there's anything I'm missing.
For the color presets, a PHP function converts these to CSS vars. This is something I'm not too confident about. I'm open to other options if anyone know of any.
Testing Instructions
Use of AI Tools
OpenCode / Codex