Skip to content

Commit

Permalink
Font Size Picker: Remove Custom option from FontSizePickerSelect drop…
Browse files Browse the repository at this point in the history
…down
  • Loading branch information
himanshupathak95 committed Feb 5, 2025
1 parent edbd360 commit dbde85e
Showing 1 changed file with 4 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,8 @@ const DEFAULT_OPTION: FontSizePickerSelectOption = {
value: undefined,
};

const CUSTOM_OPTION: FontSizePickerSelectOption = {
key: 'custom',
name: __( 'Custom' ),
};

const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
const {
__next40pxDefaultSize,
fontSizes,
value,
disableCustomFontSizes,
size,
onChange,
onSelectCustom,
} = props;
const { __next40pxDefaultSize, fontSizes, value, size, onChange } = props;

const areAllSizesSameUnit = !! getCommonSizeUnit( fontSizes );

Expand All @@ -59,12 +46,10 @@ const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
hint,
};
} ),
...( disableCustomFontSizes ? [] : [ CUSTOM_OPTION ] ),
];

const selectedOption = value
? options.find( ( option ) => option.value === value ) ?? CUSTOM_OPTION
: DEFAULT_OPTION;
const selectedOption =
options.find( ( option ) => option.value === value ) ?? DEFAULT_OPTION;

return (
<CustomSelectControl
Expand All @@ -86,11 +71,7 @@ const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
}: {
selectedItem: FontSizePickerSelectOption;
} ) => {
if ( selectedItem === CUSTOM_OPTION ) {
onSelectCustom();
} else {
onChange( selectedItem.value );
}
onChange( selectedItem.value );
} }
size={ size }
/>
Expand Down

0 comments on commit dbde85e

Please sign in to comment.