diff --git a/packages/block-editor/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js b/packages/block-editor/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js index 9943978c15af18..d822dd200b626d 100644 --- a/packages/block-editor/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js +++ b/packages/block-editor/src/components/spacing-sizes-control/hooks/use-spacing-sizes.js @@ -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 ) ); } diff --git a/schemas/json/theme.json b/schemas/json/theme.json index bdfea7279f67ac..277bc2a7782bc4 100644 --- a/schemas/json/theme.json +++ b/schemas/json/theme.json @@ -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.",