Skip to content

Commit

Permalink
Block-Editor: Enhance FontFamily Component
Browse files Browse the repository at this point in the history
When we have too many fonts, SelectControl shows font list whose height is equal to screen height in the Chrome. But in Firefox height is not that much larger.

SelectControl uses default HTML select interface, however CustomSelectControl uses custom interface, so user can see scrollable list instead of taller list. This way we can enhacne the UI

Fixes WordPress#57301.
  • Loading branch information
Utsav-Ladani committed Jul 28, 2024
1 parent 313246a commit 0470bb5
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/block-editor/src/components/font-family/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { SelectControl } from '@wordpress/components';
import { CustomSelectControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
Expand All @@ -25,21 +25,21 @@ export default function FontFamilyControl( {
}

const options = [
{ value: '', label: __( 'Default' ) },
{ key: '', name: __( 'Default' ) },
...fontFamilies.map( ( { fontFamily, name } ) => {
return {
value: fontFamily,
label: name || fontFamily,
key: fontFamily,
name: name || fontFamily,
};
} ),
];

return (
<SelectControl
<CustomSelectControl
label={ __( 'Font' ) }
options={ options }
value={ value }
onChange={ onChange }
labelPosition="top"
value={ options.find( ( { key } ) => key === value ) }
onChange={ ( { selectedItem } ) => onChange( selectedItem.key ) }
{ ...props }
/>
);
Expand Down

0 comments on commit 0470bb5

Please sign in to comment.