Skip to content

Commit

Permalink
Restore previous logic for determining hasUnits
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Oct 13, 2022
1 parent 476217a commit ab52205
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/components/src/font-size-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ const UnforwardedFontSizePicker = (
selectedOption.name
);

// If neither the value or first font size is a string, then FontSizePicker
// operates in a legacy "unitless" mode where UnitControl can only be used
// to select px values and onChange() is always called with number values.
const hasUnits =
typeof value === 'string' || typeof fontSizes[ 0 ].size === 'string';

const [ valueNumber, valueUnit ] = parseNumberAndUnitFromSize( value );
const isValueUnitRelative =
!! valueUnit && [ 'em', 'rem' ].includes( valueUnit );
const [ , firstFontSizeUnit ] = parseNumberAndUnitFromSize(
fontSizes[ 0 ]?.size
);
const hasUnits = !! valueUnit || !! firstFontSizeUnit;

return (
<Container ref={ ref } className="components-font-size-picker">
Expand Down

0 comments on commit ab52205

Please sign in to comment.