Skip to content

Conversation

@USERSATOSHI
Copy link
Contributor

What?

Closes #71628

This PR fixes the handling of border radius presets in block patterns, ensuring that custom radiusSizes defined in a theme’s theme.json are correctly referenced in generated pattern code. It also adds comprehensive unit tests for the utility functions responsible for this logic.

Why?

Previously, when using custom border radius presets, the generated block pattern code would sometimes output raw values or invalid preset references (e.g., using the raw clamp value or var:preset|border-radius|0 instead of "0" for "None"). This led to inconsistencies and made it difficult to maintain design token references in patterns.

This PR ensures:

  • The "None" preset (slug "0") always serializes as "0", not as a preset reference.
  • Preset references are preserved and correctly used in block attributes and pattern serialization.
  • The utility functions are robustly tested to prevent regressions.

How?

  • Updated getPresetValueFromCustomValue and getPresetValueFromControlValue in border-radius-control/utils.js to handle the "0" slug and preset references correctly.
  • Added unit tests to test the changes.

Testing Instructions

Follow the reproduction steps from #71628

Other than that Unit tests should suffice.

Screenshots

After fix

@github-actions
Copy link

github-actions bot commented Sep 12, 2025

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @EldarAgalarov.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: EldarAgalarov.

Co-authored-by: USERSATOSHI <tusharbharti@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Sep 13, 2025
@t-hamano
Copy link
Contributor

@USERSATOSHI Thanks for the PR!

@aaronrobertshaw @ramonjd @andrewserong, can you take a look at this PR if you have the bandwidth?

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR and especially the added tests @USERSATOSHI 👍

I've taken this PR for a test drive and it fixes the reported issue for me.

It appears though that there are some unnecessary code changes which we should probably clean up before merging this one.

Additionally, when attempting to replicate the original issue I found that there were other inconsistencies with the serialization of preset values from this control e.g. sometimes if two corners used the same preset, only one would get the var preset string etc. The removal of the call to decodeValue looks to have cleaned this up as well.

Copy link
Contributor

@aaronrobertshaw aaronrobertshaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick iterations here @USERSATOSHI 🚀

This is testing well for me. Border presets are correctly applied:

✅ In block, site, and pattern editors
✅ on the frontend
✅ via global styles
✅ when overriding global styles with block instance styles

There was a failing test that looks unrelated so I've kicked off those tests again. Also, there's a small nit/suggestion for the new tests.

Other than that, I think this is pretty much good to go.

Appreciate all the work on this one 🙇

@aaronrobertshaw aaronrobertshaw merged commit cd79457 into WordPress:trunk Sep 16, 2025
105 of 106 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.7 milestone Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BorderRadius Presets: Generating wrong variable names in pattern code

3 participants