Skip to content

Global Styles: unlinking border sides saves null values and copies a shorthand width into each side #84814

Open

Description

@iamtakashi

Description

Unlinking the border sides of a block in Global Styles has two problems when the theme sets a border on that block in theme.json:

  1. Null values are saved. The editor writes "color": null, "style": null, "width": null into the user's global styles and saves them. Tools that export global styles into a theme (such as Create Block Theme) then copy the nulls into theme.json, which the theme.json schema rejects.
  2. A shorthand width is copied into each side. If the theme's width uses the shorthand (for example "0 0 0 2px"), unlinking copies that whole string into each side. border-top-width: 0 0 0 2px is not valid CSS, so the browser falls back to the default width, and the top, right and bottom borders appear (about 3px). Changing only the left border turns the block into a full box.

Step-by-step reproduction instructions

  1. Activate Twenty Twenty-Five. Its theme.json has styles.blocks["core/quote"].border: {"style":"solid","width":"0 0 0 2px","color":"currentColor"}.
  2. Go to Site Editor → Styles → Blocks → Quote → Borders.
  3. Click "Unlink sides".
  4. Set the left width to 4px.
  5. Look at the Quote preview, then save.

Expected

  • The saved global styles contain only the per-side values that were set, with no null keys.
  • The other sides keep what the theme showed: no border on top, right and bottom.

Actual

The edited and saved global styles for core/quote:

{"border":{"color":null,"style":null,"width":null,"top":{"style":"solid","width":"0 0 0 2px","color":"currentColor"},"right":{"style":"solid","width":"0 0 0 2px","color":"currentColor"},"bottom":{"style":"solid","width":"0 0 0 2px","color":"currentColor"},"left":{"style":"solid","width":"4px","color":"currentColor"}}}

The generated CSS:

:root :where(.wp-block-quote){border-top-color: currentColor;border-top-width: 0 0 0 2px;border-top-style: solid;border-right-color: currentColor;border-right-width: 0 0 0 2px;border-right-style: solid;border-bottom-color: currentColor;border-bottom-width: 0 0 0 2px;border-bottom-style: solid;border-left-color: currentColor;border-left-width: 4px;border-left-style: solid; ...}

The Quote preview shows a border on all four sides.

On our team's themes repo, 55 themes have these null border keys in theme.json, most from exporting styles edited this way.

Environment info

  • WordPress 7.1.3
  • Gutenberg 24.2.0
  • Twenty Twenty-Five
  • Chrome, macOS

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

Yes

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

No (Jetpack and Theme Check were also active)

Please confirm which theme type you used for testing.

Block

Drafted with AI assistance, reproduced and verified by me.

Activity

  1. SainathPoojary commented on Oct 15, 2026

    @SainathPoojary
    Member

    Thanks for reporting this issue @iamtakashi! I was able to reproduce this on my end as well by following the steps provided.

    Image Image

    I am currently investigating this further, will share updates soon.

    Environment

    • WordPress: 7.1-alpha-62482
    • Gutenberg: 24.2.0
    • Theme: Twenty Twenty-Five 1.5
    • PHP: 8.3.33
    • Browser: Chrome 155.0.0.0
    • OS: macOS
  2. SainathPoojary commented on Oct 15, 2026

    @SainathPoojary
    Member

    I’ve put up #84826 to address the shorthand width problem. It updates BorderBoxControl to properly unpack strings like 0 0 0 2px into each side so valid CSS is produced when unlinking.

    Since the two reported issues live in different areas, it seemed better to split them into separate PRs to make reviewing and testing easier.

  3. added
    Global Styles
    on Oct 19, 2026
  4. added
    [Status] In Progress
    on Nov 6, 2026
  5. kmlyz commented on Nov 19, 2026

    @kmlyz
    Contributor

    Tested WP_Theme_JSON_Gutenberg::merge() (lib/class-wp-theme-json-gutenberg.php:4752) without the color: null, style: null, width: null properties from normalizeBorderStyle (packages/global-styles-ui/src/screen-block.tsx:103-108).

    When a theme sets flat border values (color, style, width) and the user layer only stores split sides (top, left), array_replace_recursive keeps the theme's flat border-color, border-width, and border-style alongside border-top-* and border-left-* in the generated stylesheet. That causes unedited or cleared sides to inherit the theme's flat border.

    I closed #86428 to avoid introducing that regression. Should this be fixed by filtering null border keys during theme export, or by updating WP_Theme_JSON_Gutenberg and global-styles-engine so split border keys supersede lower-layer flat border properties?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global Styles[Status] In Progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions