diff --git a/packages/components/src/font-size-picker/index.js b/packages/components/src/font-size-picker/index.js index 16329316d5ad1..2908b3879c1eb 100644 --- a/packages/components/src/font-size-picker/index.js +++ b/packages/components/src/font-size-picker/index.js @@ -6,8 +6,7 @@ import { map } from 'lodash'; /** * WordPress dependencies */ -import { __, _x } from '@wordpress/i18n'; -import { withInstanceId } from '@wordpress/compose'; +import { __, _x, sprintf } from '@wordpress/i18n'; /** * Internal dependencies @@ -37,6 +36,7 @@ function FontSizePicker( { }; const currentFont = fontSizes.find( ( font ) => font.size === value ); + const currentFontSizeName = ( currentFont && currentFont.name ) || ( ! value && _x( 'Normal', 'font size name' ) ) || _x( 'Custom', 'font size name' ); return ( @@ -51,26 +51,34 @@ function FontSizePicker( { isLarge onClick={ onToggle } aria-expanded={ isOpen } - aria-label={ __( 'Custom font size' ) } + aria-label={ sprintf( + /* translators: %s: font size name */ + __( 'Font size: %s' ), currentFontSizeName + ) } > - { ( currentFont && currentFont.name ) || ( ! value && _x( 'Normal', 'font size name' ) ) || _x( 'Custom', 'font size name' ) } + { currentFontSizeName } ) } renderContent={ () => ( - { map( fontSizes, ( { name, size, slug } ) => ( - - ) ) } + { map( fontSizes, ( { name, size, slug } ) => { + const isSelected = ( value === size || ( ! value && slug === 'normal' ) ); + + return ( + + ); + } ) } ) } /> @@ -90,7 +98,6 @@ function FontSizePicker( { onClick={ () => onChange( undefined ) } isSmall isDefault - aria-label={ __( 'Reset font size' ) } > { __( 'Reset' ) } @@ -112,4 +119,4 @@ function FontSizePicker( { ); } -export default withInstanceId( FontSizePicker ); +export default FontSizePicker;