WordPress / gutenberg

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

Multiple Blocks: Padding setting in JSON is no longer working #61011

Open iamtakashi opened 5 months ago

iamtakashi commented 5 months ago

Description

This is likely caused by the work reducing the specificity, but now, with the Gutenberg plugin active, the default overrides the padding for the blocks that use unordered or ordered list elements.

I've noticed this issue in the following blocks, but there might be more.

Step-by-step reproduction instructions

  1. Go to the editor
  2. Add one of the blocks affected by this issue
  3. Change the padding for the block in the JSON
  4. Notice it's overridden by the default
  5. Deactivate Gutenberg plugin, and see the difference.

Screenshots, screen recording, code snippet

CleanShot 2024-04-23 at 17 42 18@2x

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

annezazu commented 5 months ago

@tellthemachines if I remember correctly, you have been doing work around specificity. Mind taking a look?

tellthemachines commented 5 months ago

@iamtakashi which theme are you testing with? I can't find that :where(ol,ul) rule anywhere in core so assume it's coming from a theme stylesheet? Theme stylesheets are loaded after block global styles in the DOM so they will override global styles.

t-hamano commented 5 months ago

:where(ol,ul) is probably defined by Twenty Twenty-Four theme. This is because the List block uses element as a selector. I was able to reproduce this issue with a customized TT4 theme.

Testing Instructions

WP6.5

image

Latest Gutenberg

image

The fundamental problem may be that the List block's selector affects other blocks. #56469 has been submitted to add the block class name to the List block selector.

tellthemachines commented 5 months ago

Oh, good detective work there @t-hamano ! Yes, that's a side-effect of the specificity reduction but ultimately the best solution would be a classname for the list block.

iamtakashi commented 5 months ago

Hi @tellthemachines @t-hamano, Thanks for looking into it.

Yes, I usually set padding to the List block like TT4 and other list type blocks accordingly, and the padding value can vary depending on the block.

aaronrobertshaw commented 4 months ago

It's also worth noting that Gutenberg's reset stylesheet for the iframed editor will have a non-zero specificity as well. Any stylesheet that adds styles for ul,ol will break global styles configuration on these blocks. For example, Twenty Twenty One's padding styles reset for lists.