wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

Ensure root selector (body) is not wrapped in :root :where()

Open talldan opened this issue 1 year ago • 4 comments

Trac ticket: https://core.trac.wordpress.org/ticket/61704 Gutenberg issue: https://github.com/WordPress/gutenberg/issues/63712 Gutenberg PR: https://github.com/WordPress/gutenberg/pull/63726

What?

In WordPress 6.6, there was a general effort to lower and level specificity, but a couple of selectors seem to have mistakenly had their specificity raised.

The styles associated with the body are an example. In 6.5 these styles used the simple body selector. In 6.6 the selector is :root :where(body), an increase in specificity.

Why?

These changes may cause some problems for themes, especially the typography styles in the body, which will cascade.

How?

Reverts the selector back to body

Note that unlike the gutenberg PR, the core backport only affects the frontend styles. The editor styles will be fixed by updating the packages from gutenberg.

props to @aaronrobertshaw for pointing me to the fix

Testing Instructions

  1. Open the site editor
  2. Click the editor area to open the editor
  3. Click 'View site' to view the frontend
  4. Insect the body element's styles
  5. Using the browser dev tools, check that the styles are like 'expected' snippet below, with a simple body selector and not a :root :where(body) selector.

Expected:

body {
    --wp--style--root--padding-top: 115px;
    --wp--style--root--padding-right: var(--wp--preset--spacing--50);
    --wp--style--root--padding-bottom: 115px;
    --wp--style--root--padding-left: var(--wp--preset--spacing--50);
    color: var(--wp--preset--color--contrast);
    background-color: var(--wp--preset--color--base);
    font-family: var(--wp--preset--font-family--body);
    font-size: var(--wp--preset--font-size--medium);
    font-style: normal;
    font-weight: 400;
    line-height: 1.55;
}

Before:

:root :where(body) {
    --wp--style--root--padding-top: 115px;
    --wp--style--root--padding-right: var(--wp--preset--spacing--50);
    --wp--style--root--padding-bottom: 115px;
    --wp--style--root--padding-left: var(--wp--preset--spacing--50);
    color: var(--wp--preset--color--contrast);
    background-color: var(--wp--preset--color--base);
    font-family: var(--wp--preset--font-family--body);
    font-size: var(--wp--preset--font-size--medium);
    font-style: normal;
    font-weight: 400;
    line-height: 1.55;
}

This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

talldan avatar Jul 19 '24 05:07 talldan

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props talldanwp, andrewserong, aaronrobertshaw, mukesh27, hellofromtonya.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

github-actions[bot] avatar Jul 19 '24 05:07 github-actions[bot]

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance, it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

github-actions[bot] avatar Jul 19 '24 05:07 github-actions[bot]

Thanks for spotting that. Linty things should be all fixed in the last two commits 👍

talldan avatar Jul 19 '24 07:07 talldan

Thanks the @since and @ticket comments LGTM 👍

aaronrobertshaw avatar Jul 19 '24 07:07 aaronrobertshaw

Committed in r58856

talldan avatar Aug 06 '24 08:08 talldan