Reduce duplicated preset utility implementations#80245
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: +33 B (0%) Total Size: 7.72 MB 📦 View Changed
|
|
Flaky tests detected in 261d827. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29420557510
|
jeryj
left a comment
There was a problem hiding this comment.
Functionally looks good. Approving but I think we should remove the getPresetSlug test.
| } ); | ||
|
|
||
| describe( 'getSpacingPresetSlug', () => { | ||
| describe( 'getPresetSlug', () => { |
There was a problem hiding this comment.
Haven't looked yet, but I assume these tests already exist within getPresetSlug from preset-input-control? I think we could just get rid of these tests if they are tested within preset-input-control.
| @@ -64,10 +71,7 @@ export const VIEWS = { | |||
| * @return {boolean} Return true if value is string in format var:preset|spacing|. | |||
| */ | |||
| export function isValueSpacingPreset( value ) { | |||
There was a problem hiding this comment.
If isValuePreset( value, SPACING_PRESET_TYPE ) handles it, maybe we use that instead? Or is isvalueSpacingPreset publicly exported?
There was a problem hiding this comment.
Ah, it is publicly exported. Nevermind.
What?
Reduces duplicated preset utility implementations in the block editor spacing and border radius controls.
Why?
Spacing and border radius controls had overlapping helper logic for identifying preset values, extracting preset slugs, and resolving preset values. Keeping that logic centralized makes future preset behavior changes less likely to drift between controls.
How?
isValueSpacingPresetexport for backwards compatibility.Testing Instructions
Run
npm run test:unit -- packages/block-editor/src/components/spacing-sizes-control/test/utils.js packages/block-editor/src/components/border-radius-control/test/utils.js packages/block-editor/src/components/preset-input-control/test/utils.js.Testing Instructions for Keyboard
No keyboard-specific testing is needed because this refactors shared helper implementations without changing UI behavior.
Screenshots or screencast
Not applicable.
Use of AI Tools
This PR was authored with assistance from OpenAI Codex in Conductor; the generated changes were reviewed before submission.