From aa91684eb5e58384e6d9b6244d7d9dd3791ffb52 Mon Sep 17 00:00:00 2001 From: Glen Davies Date: Wed, 22 Nov 2023 10:21:22 +1300 Subject: [PATCH] Spacing theme.json - check that the first item in the units array is defined before trying to assign its value (#56306) --- .../input-controls/spacing-input-control.js | 2 +- schemas/json/theme.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js b/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js index a7efd10bce7125..7ef5c17f82943c 100644 --- a/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js +++ b/packages/block-editor/src/components/spacing-sizes-control/input-controls/spacing-input-control.js @@ -139,7 +139,7 @@ export default function SpacingInputControl( { useMemo( () => parseQuantityAndUnitFromRawValue( currentValue ), [ currentValue ] - )[ 1 ] || units[ 0 ].value; + )[ 1 ] || units[ 0 ]?.value; const setInitialValue = () => { if ( value === undefined ) { diff --git a/schemas/json/theme.json b/schemas/json/theme.json index 8414c939c8c7ae..5a24f1b16c1a35 100644 --- a/schemas/json/theme.json +++ b/schemas/json/theme.json @@ -364,7 +364,8 @@ "items": { "type": "string" }, - "default": [ "px", "em", "rem", "vh", "vw", "%" ] + "default": [ "px", "em", "rem", "vh", "vw", "%" ], + "minItems": 1 }, "customSpacingSize": { "description": "Allow users to set custom space sizes.",