Skip to content

Commit

Permalink
Components: Improve FontSizePicker units documentation and fix unit f…
Browse files Browse the repository at this point in the history
…iltering
  • Loading branch information
himanshupathak95 committed Jan 29, 2025
1 parent 35ba7ef commit 862c5ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/components/src/font-size-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]`

Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/unit-control/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 862c5ed

Please sign in to comment.