Skip to content

Commit

Permalink
Remove the memo because it's probably fine
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlende committed Dec 7, 2023
1 parent 854bafd commit fd7da57
Showing 1 changed file with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
__experimentalToolsPanelItem as ToolsPanelItem,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { useCallback, useMemo } from '@wordpress/element';
import { useCallback } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -23,7 +23,6 @@ import TextDecorationControl from '../text-decoration-control';
import WritingModeControl from '../writing-mode-control';
import { getValueFromVariable } from './utils';
import { setImmutably, uniqByProperty } from '../../utils/object';
import { use } from '@wordpress/data';

const MIN_TEXT_COLUMNS = 1;
const MAX_TEXT_COLUMNS = 6;
Expand Down Expand Up @@ -139,22 +138,6 @@ const DEFAULT_CONTROLS = {
textColumns: true,
};

function useMergedFontSizes( settings ) {
return useMemo( () => {
return uniqByProperty(
mergeOrigins( {
default:
settings?.typography?.defaultFontSizes !== false
? settings?.typography?.fontSizes?.default
: undefined,
theme: settings?.typography?.fontSizes?.theme,
custom: settings?.typography?.fontSizes?.custom,
} ),
'slug'
);
}, [ settings ] );
}

export default function TypographyPanel( {
as: Wrapper = TypographyToolsPanel,
value,
Expand Down Expand Up @@ -192,8 +175,17 @@ export default function TypographyPanel( {
// Font Size
const hasFontSizeEnabled = useHasFontSizeControl( settings );
const disableCustomFontSizes = ! settings?.typography?.customFontSize;
const fontSizes = useMergedFontSizes( settings );

const mergedFontSizes = uniqByProperty(
mergeOrigins( {
default:
settings?.typography?.defaultFontSizes !== false
? settings?.typography?.fontSizes?.default
: undefined,
theme: settings?.typography?.fontSizes?.theme,
custom: settings?.typography?.fontSizes?.custom,
} ),
'slug'
);
const fontSize = decodeValue( inheritedValue?.typography?.fontSize );
const setFontSize = ( newValue, metadata ) => {
const actualValue = !! metadata?.slug
Expand Down Expand Up @@ -375,7 +367,7 @@ export default function TypographyPanel( {
<FontSizePicker
value={ fontSize }
onChange={ setFontSize }
fontSizes={ fontSizes }
fontSizes={ mergedFontSizes }
disableCustomFontSizes={ disableCustomFontSizes }
withReset={ false }
withSlider
Expand Down

0 comments on commit fd7da57

Please sign in to comment.