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 and ellatrix committed Jun 18, 2024
1 parent b8852af commit 401395a
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

0 comments on commit 401395a

Please sign in to comment.