Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
iamtakashi opened this issue Apr 23, 2024 · 6 comments
Open

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

iamtakashi opened this issue Apr 23, 2024 · 6 comments
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Bug An existing feature does not function as intended

Comments

@iamtakashi
Copy link

iamtakashi commented Apr 23, 2024

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.

  • Archives Block,
  • Categories List Block,
  • Latest Comments Block,
  • Table of Contents Block (the cause might be a different issue)

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

  • WP 6.5.2
  • Gutenberg Trunk

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

@iamtakashi iamtakashi added the [Type] Bug An existing feature does not function as intended label Apr 23, 2024
@annezazu
Copy link
Contributor

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

@annezazu annezazu added the CSS Styling Related to editor and front end styles, CSS-specific issues. label Apr 23, 2024
@tellthemachines
Copy link
Contributor

@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
Copy link
Contributor

: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

  • Activate TT4 theme.
  • In theme.json, add the following code:
    {
    	...
    	"styles": {
    		"blocks": {
    			...
    			"core/archives": {
    				"spacing": {
    					"padding": {
    						"left": "3em"
    					}
    				}
    			},
    			...
    		},
    		...
    	},
    	...
    }
  • Insert an Archive block.
  • Check the CSS applied on the front end.

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants