Editor: allow selecting which block styles to apply globally#79839
Conversation
|
Size Change: +2.63 kB (+0.03%) Total Size: 7.72 MB 📦 View Changed
|
|
I've left this one in a draft state for the moment as it is more on the proof of concept stage for now until we confirm design direction etc. @WordPress/gutenberg-design would you have a moment to share a few thoughts here? |
|
Flaky tests detected in f72c3e4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29463874377
|
|
Just gave this a spin! I really like being able to see "current" to "new" and the way the granularity is presented. It makes me want to change our multi-entity saving flow. I think this works really well. I did run into a weird situation at the end though where I was getting blank pages when navigating to a template part: failed.movI could replicate it after going in and out of the editor so not sure what's going on. There's a chance it's playground. Finally, I noticed that after pushing styles globally, the styling is reset aka it shows as empty options rather than as inherited styles: globaly.chnges.mov |
|
Thanks for the early testing @annezazu 🙇
I haven't come across this one yet using my local env so I'll have to do some digging.
If I follow what you are saying correctly, this is because this PR is a standalone feature and completely separate to #77894 which is attempting to display inherited global styles within the block inspector. So if the styles that were pushed to global styles are still being applied correctly on the canvas then it would appear this feature is working correctly. |
Ah ha! You are correct.
This might be some Playground weirdness as a heads up. Overall though, I like how this is coming together. |
|
This is pretty cool, and works well. It uses DataViews yes? Arguably this is such an improveent over trunk, and a step in the right direction, that I don't know it needs too much design feedback. I will share some in a minute, but as-is, it solve a fundamental problem with the "Apply styles globally" being a very dangerous action, that I think it can land almost as-is. The feedback to consider is minimal: I'm not sure what the chevron-right icon means. There could be a good reason, does it expand anything? But absent that, I'd remove it. The larger picture is: while this decides which styles to propogate elsewhere, the interface is touching on one we need for to be generic across a few similar actions:
... and anything else in that matrix. There's some older artwork for this by our friend Channing which puts it in the pre-publish sidebar, but with other changes it should today live in a modal. But there are instincts and concepts there still absorbing. |
|
Thanks for weighing in @jasmussen, appreciate it 👍
The chevron was meant as a placeholder for what was in the design mockup shared over on another PR. I did mean to clean it up but straight up removal might be the better option.
I'll get the chevron removed, polish up a couple of things and flag this for review with a view to merge. It would be nice to sneak into 7.1 if possible. |
|
Yay! Thank you for reviewing, Joen. I would love to see this land and agree this is a big improvement over what's there now, adding nice "good friction". |
|
This feature is a great UX improvement built on top of existing APIs, and it does not expose any new APIs or affect backward compatibility. It might not make it in time for Beta 1, but how about we aim to ship it for Beta 2? |
af65144 to
def3592
Compare
The "Apply globally" control previously pushed all of a block's modified styles to Global Styles at once. It now opens a review table where each changed style is listed with its current and new value, so the user can choose the subset to apply and leave the rest as local overrides. Refactors push-to-global-styles into grouped, testable change rows and adds unit and E2E coverage.
The apply-globally rewrite grew this file from 2 to 7 JSDoc blocks. Convert the two internal border helpers to one-line comments (their 'why' is already stated as inline comments in the bodies) and condense the descriptions on the exported getChangesToPush/getStylesUpdate. Keep the ChangeRow typedef and the exported functions' param/return contracts.
The predicate value !== undefined && value !== null && value !== '' was repeated four times across formatStyleValue, formatBorderShorthand, formatBorderRadius, and formatSpacingShorthand. Extract a single module-level isSet helper and reuse it.
a5a199a to
f72c3e4
Compare
|
Given the approvals and all feedback received being resolved. I'll get this one merged once the tests pass. Additionally, I've added the |
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: jasmussen <joen@git.wordpress.org> Co-authored-by: ramonjd <ramonopoly@git.wordpress.org> Co-authored-by: annezazu <annezazu@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: fcoveram <fcoveram@git.wordpress.org>
|
I just cherry-picked this PR to the wp/7.1 branch to get it included in the next release: 3d64ddc |

What?
Alternative to: #79719
Adds a review step to the block inspector's Apply globally action. Instead of immediately pushing every changed style to Global Styles, the button now opens a modal listing each modified style with its current and new value, and only the styles you keep selected are applied.
Why?
Today the button is all-or-nothing: a single click writes every detected change into Global Styles for that block type, with no chance to see what will change or leave some of it behind. Surfacing the changes as a pre-selected checklist makes the action reviewable and lets you push just the styles you mean to.
How?
useChangesToPushto return grouped rows rather than a flat list of paths, so border shorthand, its per-side values, andsolidfallbacks collapse into a single "Border color" row that pushes together.useReviewRowshook that decorates each row with a readable label, the effective current Global Styles value for the block type, and formatted current/new values.pushChangesaccept a selected subset and clears preset attributes (textColor,backgroundColor,borderColor, etc.) conditionally, so a deselected preset style is neither pushed nor wiped from the block. Early-returns on an empty subset; the existing Undo snackbar is untouched.style-labelsmap (with acapitalCasefallback) and aformat-style-valueutil that resolves preset tokens to readable slugs and collapses spacing/border/radius objects to CSS shorthand.ApplyGloballyModal(usingDataViewsPicker) with a selection checkbox, style name, current value, a subdued arrow, and the new value. All rows selected by default; Apply is disabled with nothing selected; Cancel/close/Escape do nothing.Note: The tricky bits — row grouping and the conditional preset clearing — are pulled out into pure
getChangesToPush()/getStylesUpdate()helpers and unit tested directly.Note: The "current" value shown is the merged/effective Global Styles value for the block type, i.e. what the block currently resolves to.
Testing Instructions
Screenshots or screencast
Screen.Recording.2026-07-02.at.7.04.34.pm.mp4