Global Styles: move pseudo-state slicing logic into useStyle hook#77104
Global Styles: move pseudo-state slicing logic into useStyle hook#77104MaggieCabrera wants to merge 1 commit intotrunkfrom
useStyle hook#77104Conversation
|
Size Change: +27 B (0%) Total Size: 7.74 MB 📦 View Changed
ℹ️ View Unchanged
|
|
Flaky tests detected in 354b7c8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/24089380466
|
|
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. |
mikachan
left a comment
There was a problem hiding this comment.
These code changes read well to me, and I can see they address part of this feedback. I think this is good to bring in 👍
This PR partially addresses some of the feedback on #76491
When #75627 landed,
ScreenBlockneeded to display style controls scoped to a pseudo-state (:hover, :focus, etc.). The way it did that was: fetch the entire style object for the block, then manually slice out the relevant state sub-object before passing it to the panels, and on save, manually re-nest the updated value back under the state key before writing. That logic lived directly inScreenBlock, it wasn't part of the hook.The problem is that
useStyleis supposed to be the single abstraction for "read/write a style value in Global Styles." But state awareness was leaking out of it into the component. Any other screen that wanted state support in the future would have to copy the same slicing pattern.Moving that logic into useStyle itself means the hook now fully owns the concern of "where in the config does this value live". The component just says what it wants (color.text for :hover) and the hook handles the rest.
Use of AI Tools
This PR was authored with Claude Code (Claude Opus 4.6).