@@ -25,18 +25,17 @@ import {
2525 __experimentalGetSpacingClassesAndStyles as useSpacingProps ,
2626 getDimensionsClassesAndStyles as useDimensionsProps ,
2727} from '@wordpress/block-editor' ;
28- import { useSelect } from '@wordpress/data' ;
29- import { store as coreDataStore } from '@wordpress/core-data' ;
3028import { useState } from '@wordpress/element' ;
3129import { SVG , Rect , Path } from '@wordpress/primitives' ;
30+ import { useSelect } from '@wordpress/data' ;
31+ import { store as coreDataStore } from '@wordpress/core-data' ;
3232
3333/**
3434 * Internal dependencies
3535 */
3636import { useToolsPanelDropdownMenuProps } from '../utils/hooks' ;
3737import HtmlRenderer from '../utils/html-renderer' ;
3838import { CustomInserterModal } from './components' ;
39- import { unlock } from '../lock-unlock' ;
4039
4140const IconPlaceholder = ( { className, style } ) => (
4241 < SVG
@@ -70,14 +69,25 @@ export function Edit( { attributes, setAttributes } ) {
7069 const borderProps = useBorderProps ( attributes ) ;
7170 const dimensionsProps = useDimensionsProps ( attributes ) ;
7271
73- const allIcons = useSelect ( ( select ) => {
74- return unlock ( select ( coreDataStore ) ) . getIcons ( ) ;
75- } , [ ] ) ;
72+ const { selectedIcon, allIcons = [ ] } = useSelect (
73+ ( select ) => {
74+ const { getEntityRecord, getEntityRecords } =
75+ select ( coreDataStore ) ;
76+ return {
77+ selectedIcon : icon
78+ ? getEntityRecord ( 'root' , 'icon' , icon )
79+ : null ,
80+ allIcons : isInserterOpen
81+ ? getEntityRecords ( 'root' , 'icon' , {
82+ per_page : - 1 ,
83+ } )
84+ : undefined ,
85+ } ;
86+ } ,
87+ [ isInserterOpen , icon ]
88+ ) ;
7689
77- const iconToDisplay =
78- allIcons ?. length > 0
79- ? allIcons ?. find ( ( { name } ) => name === icon ) ?. content
80- : '' ;
90+ const iconToDisplay = selectedIcon ?. content || '' ;
8191
8292 const blockControls = (
8393 < >
0 commit comments