@@ -17,10 +17,11 @@ import {
1717 Dashicon ,
1818 Dropdown ,
1919} from '@wordpress/components'
20- import { useState , useEffect } from '@wordpress/element'
20+ import {
21+ useState , useEffect , forwardRef ,
22+ } from '@wordpress/element'
2123import { __ } from '@wordpress/i18n'
2224import { ResetButton } from '../base-control2/reset-button'
23- import { ITEM_PICKER } from './util'
2425
2526const addItemPopoverProps = {
2627 placement : 'left-start' ,
@@ -44,7 +45,7 @@ const DRAG_KEYCODES = {
4445 down : [ 40 , 39 ] ,
4546}
4647
47- const SortablePicker = props => {
48+ const SortablePicker = forwardRef ( ( props , ref ) => {
4849 const {
4950 nonSortableItems = [ ] ,
5051 editableName = true ,
@@ -55,7 +56,6 @@ const SortablePicker = props => {
5556 handleAddItem,
5657 onSortEnd,
5758 AddItemPopover = null ,
58- ref,
5959 enableAddItem = true ,
6060 } = props
6161 const [ isSorting , setIsSorting ] = useState ( false )
@@ -134,7 +134,7 @@ const SortablePicker = props => {
134134 </ div >
135135 </ BaseControl >
136136 )
137- }
137+ } )
138138
139139SortablePicker . defaultProps = {
140140 className : '' ,
@@ -260,11 +260,7 @@ const LabeledItemIndicator = props => {
260260 )
261261 } }
262262 renderContent = { ( { onClose } ) => {
263- const ItemPicker_ = typeof ItemPicker === 'string' ? ITEM_PICKER [ ItemPicker ] : null
264-
265- return typeof ItemPicker === 'string' && ItemPicker_
266- ? < ItemPicker_ item = { item } onChange = { onChange } onClose = { onClose } />
267- : < ItemPicker item = { item } onChange = { onChange } onClose = { onClose } />
263+ return < > { ItemPicker && < ItemPicker item = { item } onChange = { onChange } onClose = { onClose } /> } </ >
268264 } }
269265 />
270266 { sortable &&
0 commit comments