From 7851f6a57a5b8014ae8354c9ca0ed1b249dd40b9 Mon Sep 17 00:00:00 2001 From: himanshupathak95 Date: Wed, 29 Jan 2025 13:41:46 +0530 Subject: [PATCH] Components: Improve FontSizePicker units documentation and fix unit filtering --- packages/components/src/font-size-picker/README.md | 2 ++ packages/components/src/unit-control/utils.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/components/src/font-size-picker/README.md b/packages/components/src/font-size-picker/README.md index 39d916c0c7b21..1c0cb84da8255 100644 --- a/packages/components/src/font-size-picker/README.md +++ b/packages/components/src/font-size-picker/README.md @@ -92,6 +92,8 @@ Size of the control. Available units for custom font size selection. +**Important Note**: For the units property to work, font sizes must be specified as strings with units (e.g., `'12px'` instead of `12`). When font sizes are provided as numbers, the component operates in "unitless mode" where the units property has no effect. + - Required: No - Default: `[ 'px', 'em', 'rem', 'vw', 'vh' ]` diff --git a/packages/components/src/unit-control/utils.ts b/packages/components/src/unit-control/utils.ts index c80b34ef3af7b..7951113eadc46 100644 --- a/packages/components/src/unit-control/utils.ts +++ b/packages/components/src/unit-control/utils.ts @@ -394,11 +394,11 @@ export function filterUnitsWithSettings( // Although the `isArray` check shouldn't be necessary (given the signature of // this typed function), it's better to stay on the side of caution, since // this function may be called from un-typed environments. - return Array.isArray( availableUnits ) + return Array.isArray( availableUnits ) && Array.isArray( allowedUnitValues ) ? availableUnits.filter( ( unit ) => allowedUnitValues.includes( unit.value ) ) - : []; + : availableUnits; } /**