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

List css added via theme.json are applied globally. #56318

Closed
jdamner opened this issue Nov 20, 2023 · 1 comment
Closed

List css added via theme.json are applied globally. #56318

jdamner opened this issue Nov 20, 2023 · 1 comment
Labels
[Block] List Affects the List Block [Type] Bug An existing feature does not function as intended

Comments

@jdamner
Copy link

jdamner commented Nov 20, 2023

Description

When using the CSS configuration in the theme.json for list blocks, the selector used by WP is ol, li { ... }. This means that any CSS added here is applied at a global scope, such as to all site furniture, menus even the WP-Admin bar.

I would expect that the list block output to contain a class and then the CSS from the theme.json to be limited to that class. Ie
ol.wp-block-list, ul.wp-block-list { ... }

Step-by-step reproduction instructions

Add the following snippet to theme.json in your theme

{
  "styles": { 
    "blocks": { 
      "core/list": {
        "css": "&:not(ol) > li::marker { content: '— '; color: 'red' }"
        },
      }
    }
}

Visit the site.

Screenshots, screen recording, code snippet

See the admin-bar having the list-style applied.
Screenshot 2023-11-20 at 12 42 50

Environment info

WP 6.4.1, this will affect all browsers and environments though.

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

@jdamner jdamner added the [Type] Bug An existing feature does not function as intended label Nov 20, 2023
@t-hamano t-hamano added the [Block] List Affects the List Block label Nov 20, 2023
@t-hamano
Copy link
Contributor

Thanks for the report.

This issue was also proposed a long time ago in #12420. As a temporary solution, the code in this comment might be helpful.

@jdamner jdamner closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] List Affects the List Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

2 participants