WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.23k stars 4.08k forks source link

Add the option to turn off "apply globally" option #47256

Open annezazu opened 1 year ago

annezazu commented 1 year ago

What problem does this address?

While discussing this new option to apply styles globally https://github.com/WordPress/gutenberg/pull/46446 in a hallway hangout for the FSE Outreach Program, a discussion was started around having the ability to turn this option off for folks, similar to what we have around tooling to curate the editor experience.

What is your proposed solution?

Provide a way to disable this, perhaps through a theme.json option. cc @andrewserong since you helped me with the last piece of feedback around this issue!

andrewserong commented 1 year ago

Oh, very interesting, thanks for the ping and raising the feedback here! I'll also ping @noisysocks since he's been working on this feature, too.

Out of curiosity, what's the reasoning surrounding wanting to disable the control? I believe the feature is only available in the site editor for now, where the current user is already able to make changes to the global styles for the current block. So, for other areas where the experience is curated in terms of disabling margin / padding, etc, if we hide the "apply globally" option, it's more that a particular button is hidden, rather than that the user is prevented from being able to make global changes to the block.

The main reason I'm curious is to hone in if we add the ability to disable the control, what is the scope of the thing that folks are trying to disable? I.e. is it the button they want to hide, or are they wanting to be able to prevent users from changing global styles for a particular set of blocks?

Overall, I'm very much in favour of ensuring folks can curate the editor experience how they like, though!

noisysocks commented 1 year ago

Definitely doable. Would also like to understand more about the motivation for this.

annezazu commented 1 year ago

I can do you one better! Here's the section of the video of the hallway hangout where we talked about this so you can hear the discussion live. Listen until the 10:35 mark and that's the bulk of the discussion.

Otherwise, essentially the reason for wanting to turn this off is because it's a powerful feature that overwrites things globally. Unless folks really understand what's going on, this feature likely isn't for everyone and it always helps to be able to turn things off.

They are wanting to prevent folks from overwriting globally from that pathway specifically to be clear rather than turning off Styles as a whole.

noisysocks commented 1 year ago

Thanks @annezazu!

Otherwise, essentially the reason for wanting to turn this off is because it's a powerful feature that overwrites things globally. Unless folks really understand what's going on, this feature likely isn't for everyone and it always helps to be able to turn things off.

This sentence sets off gentle alarm bells in my mind: if it's difficult to understand what's going on, shouldn't we address that rather than (allow one to) remove the feature? 😀

Noting also that the button is also underneath Advanced which is collapsed by default.

I'm curious if @jameskoster and @jasmussen have any thoughts on this as they worked on the design in https://github.com/WordPress/gutenberg/issues/44361.

Anyway, I'm still happy to add an option to theme.json. Probably we should do both things here: improve the usability of the feature and allow disabling it.

jasmussen commented 1 year ago

I think the reason we've put it in the advanced section is exactly that: it is an advanced feature. But keep in mind, before any of this goes global, you have to also confirm that you want to keep that global change in the multi entity saving panel.

I would also add, this is the same for template parts, site logo/title/tagline, reusable blocks, etc. So if we should think about turning aspects off globally, we should do it in a holistic way that considers all of those global elements, and it should very probably be tied to user roles rather than specific theme.json features or otherwise.

Stiofan commented 1 year ago

Is there really no way to disable this even per block? Its showing up in all my blocks, even ones with zero options. If it can be disabled per block then I have not found the docs and I have asked in the WP slack in multiple places.

Some core blocks seem to be lacking it so it must have a way to turn it off somehow?

Reasons it should have an option to disable it:

  1. Bad UX, its showing on blocks where it will never be used.
  2. We implemented tabbed settings long before core WP and now this breaks our implementation of it.
jameskoster commented 1 year ago

Bad UX, its showing on blocks where it will never be used.

This one is a bit different to the OP, but I agree that it doesn't make sense for this affordance to appear if the block has no style options. Hopefully it's not too difficult to add some logic to account for that.

richtabor commented 1 year ago

This one is a bit different to the OP, but I agree that it doesn't make sense for this affordance to appear if the block has no style options.

That should be a separate issue, for example Template Part and Embeds shouldn't have control. May be able to use the same logic for copy/paste styling — so blocks without block support styles wouldn't have that UI too.

richtabor commented 1 year ago

I think the reason we've put it in the advanced section is exactly that: it is an advanced feature. But keep in mind, before any of this goes global, you have to also confirm that you want to keep that global change in the multi entity saving panel.

It's in the Advanced panel only in the Site Editor experience as well. I don't think we need a way to hide the control; perhaps some sort of role-based Site Editor access may be interesting to explore one day.

Stiofan commented 1 year ago

I think the reason we've put it in the advanced section is exactly that: it is an advanced feature. But keep in mind, before any of this goes global, you have to also confirm that you want to keep that global change in the multi entity saving panel.

It's in the Advanced panel only in the Site Editor experience as well. I don't think we need a way to hide the control; perhaps some sort of role-based Site Editor access may be interesting to explore one day.

We don't and im sure many don't utilise the standard advanced block section, now it shows on all our blocks even if they have zero options. Jeez just give a way to disable per block, everything else in advance can be, why is this so special...

richtabor commented 1 year ago

Jeez just give a way to disable per block, everything else in advance can be, why is this so special...

I don't think the block-level would be appropriate for this control. It would feel broken if you can style some blocks and push those styles globally, but style other blocks and not be able to apply those globally.

Again, the logic should be tailored so that any block without block supports styles should not have the control available. That would inhibit the control from showing up on blocks that do not have block supports styles (thus solving this need for your blocks). 🙂

jordesign commented 1 year ago

I can imagine a case where a developer/builder may want to have that kind of option turned off on a theme/site-wide level to keep end users from being able to push a change globally.

noisysocks commented 1 year ago

You could always remove the button by unhooking the function that adds it to the site editor. This may stop working in a future WordPress release though.

wp.hooks.removeFilter(
    'editor.BlockEdit',
    'core/edit-site/push-changes-to-global-styles'
);
Stiofan commented 1 year ago

Jeez just give a way to disable per block, everything else in advance can be, why is this so special...

I don't think the block-level would be appropriate for this control. It would feel broken if you can style some blocks and push those styles globally, but style other blocks and not be able to apply those globally.

Again, the logic should be tailored so that any block without block supports styles should not have the control available. That would inhibit the control from showing up on blocks that do not have block supports styles (thus solving this need for your blocks). slightly_smiling_face

Many of the core blocks DONT have this showing (row block for example), so there is already a way to do it...

richtabor commented 1 year ago

Many of the core blocks DONT have this showing (row block for example), so there is already a way to do it...

Group blocks do have the "Apply globally" button, but that button is only available within the Site Editor:

CleanShot 2023-03-28 at 14 35 39
Stiofan commented 1 year ago

Many of the core blocks DONT have this showing (row block for example), so there is already a way to do it...

Group blocks do have the "Apply globally" button, but that button is only available within the Site Editor:

I'm aware it's only the Site editor. I was referring to the row block, but there are more such as the button block. Core blocks have the ability to not show this but WP Dev's don't. Either its a bug or its unfair, which is it?

noisysocks commented 1 year ago

Many of the core blocks DONT have this showing (row block for example), so there is already a way to do it...

This isn't correct. I see Apply globally on a Row block when testing locally.

Stiofan commented 1 year ago
.removeFilter

You are right, I was confusing the new style message with the advanced tab being open and empty.

It is still the case that this is the only thing the developer can't turn off, and there is really no good reason for that. Dev's can turn off everything else in "Advanced" and remove the advanced tab except this new setting which does not apply to many blocks. It's bad UX for the developer and bad UI for users.