Skip to content

Commit

Permalink
Sort spacing sizes when all slugs begin numerically (#62567)
Browse files Browse the repository at this point in the history
Co-authored-by: ajlende <[email protected]>
Co-authored-by: scruffian <[email protected]>
Co-authored-by: justintadlock <[email protected]>
  • Loading branch information
4 people authored Jun 14, 2024
1 parent 03eda5b commit a1c648f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,8 @@ export default function useSpacingSizes() {
...defaultSizes,
];

// Only sort if more than one origin has presets defined in order to
// preserve order for themes that don't include default presets and
// want a custom order.
if (
( customSizes.length && 1 ) +
( themeSizes.length && 1 ) +
( defaultSizes.length && 1 ) >
1
) {
// Using numeric slugs opts-in to sorting by slug.
if ( sizes.every( ( { slug } ) => /^[0-9]/.test( slug ) ) ) {
sizes.sort( ( a, b ) => compare( a.slug, b.slug ) );
}

Expand Down
5 changes: 2 additions & 3 deletions schemas/json/theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,8 @@
"type": "string"
},
"slug": {
"description": "Unique identifier for the space size preset. Will be sorted numerically. For best cross theme compatibility these should be in the form '10','20','30','40','50','60', etc. with '50' representing the 'Medium' size step.",
"type": "string",
"pattern": "^[0-9].*$"
"description": "Unique identifier for the space size preset. For best cross theme compatibility these should be in the form '10','20','30','40','50','60', etc. with '50' representing the 'Medium' size step. If all slugs begin with a number they will be merged with default and user slugs and sorted numerically.",
"type": "string"
},
"size": {
"description": "CSS space-size value, including units.",
Expand Down

1 comment on commit a1c648f

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in a1c648f.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9517632532
📝 Reported issues:

Please sign in to comment.