File tree Expand file tree Collapse file tree 4 files changed +26
-11
lines changed
block-editor/src/components
custom-select-control-v2/legacy-component Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Original file line number Diff line number Diff line change @@ -203,6 +203,8 @@ export default function FontAppearanceControl( props ) {
203203 ) ;
204204 } ;
205205
206+ console . debug ( 'selectOptions: ' , selectOptions ) ;
207+
206208 return (
207209 hasStylesOrWeights && (
208210 < CustomSelectControl
@@ -212,9 +214,11 @@ export default function FontAppearanceControl( props ) {
212214 describedBy = { getDescribedBy ( ) }
213215 options = { selectOptions }
214216 value = { currentSelection }
215- onChange = { ( { selectedItem } ) =>
216- onChange ( selectedItem . style )
217- }
217+ onChange = { ( { selectedItem } ) => {
218+ console . debug ( 'selectedItem:' ) ;
219+ console . debug ( selectedItem ) ;
220+ onChange ( selectedItem . style ) ;
221+ } }
218222 />
219223 )
220224 ) ;
Original file line number Diff line number Diff line change @@ -223,6 +223,8 @@ export default function TypographyPanel( {
223223 fontStyle : newFontStyle ,
224224 fontWeight : newFontWeight ,
225225 } ) => {
226+ console . debug ( fontStyle ) ;
227+ console . debug ( fontWeight ) ;
226228 onChange ( {
227229 ...value ,
228230 typography : {
Original file line number Diff line number Diff line change @@ -30,25 +30,22 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
3030 // Forward props + store from v2 implementation
3131 const store = Ariakit . useSelectStore ( {
3232 async setValue ( nextValue ) {
33- if ( ! onChange ) {
34- return ;
35- }
33+ if ( ! onChange ) return ;
3634
3735 // Executes the logic in a microtask after the popup is closed.
3836 // This is simply to ensure the isOpen state matches that in Downshift.
3937 await Promise . resolve ( ) ;
4038 const state = store . getState ( ) ;
4139
40+ const option = options . find ( ( item ) => item . name === nextValue ) ;
41+
4242 const changeObject = {
4343 highlightedIndex : state . renderedItems . findIndex (
4444 ( item ) => item . value === nextValue
4545 ) ,
4646 inputValue : '' ,
4747 isOpen : state . open ,
48- selectedItem : {
49- name : nextValue as string ,
50- key : nextValue as string ,
51- } ,
48+ selectedItem : option ! ,
5249 type : '' ,
5350 } ;
5451 onChange ( changeObject ) ;
@@ -131,3 +128,14 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
131128}
132129
133130export default CustomSelectControl ;
131+
132+ // for backwards compatibility
133+ export function ClassicCustomSelectControl ( props : LegacyCustomSelectProps ) {
134+ console . debug ( props ) ;
135+ return (
136+ < CustomSelectControl
137+ { ...props }
138+ __experimentalShowSelectedHint = { false }
139+ />
140+ ) ;
141+ }
Original file line number Diff line number Diff line change @@ -63,7 +63,8 @@ export {
6363 useCompositeState as __unstableUseCompositeState ,
6464} from './composite' ;
6565export { ConfirmDialog as __experimentalConfirmDialog } from './confirm-dialog' ;
66- export { StableCustomSelectControl as CustomSelectControl } from './custom-select-control' ;
66+ export { ClassicCustomSelectControl as CustomSelectControl } from './custom-select-control-v2/legacy-component' ;
67+ export { default as CustomSelectControlV2 } from './custom-select-control-v2' ;
6768export { default as Dashicon } from './dashicon' ;
6869export { default as DateTimePicker , DatePicker , TimePicker } from './date-time' ;
6970export { default as __experimentalDimensionControl } from './dimension-control' ;
You can’t perform that action at this time.
0 commit comments