Skip to content

Commit 752a07f

Browse files
Remove "experimental" designation for CustomSelectControl[V2] and export the legacy adapter as the classic one (WIP)
1 parent ddf0218 commit 752a07f

File tree

7 files changed

+31
-6
lines changed

7 files changed

+31
-6
lines changed

packages/block-editor/src/components/font-appearance-control/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff 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,8 +214,11 @@ export default function FontAppearanceControl( props ) {
212214
describedBy={ getDescribedBy() }
213215
options={ selectOptions }
214216
value={ currentSelection }
215-
onChange={ ( { selectedItem } ) =>
216-
onChange( selectedItem.style )
217+
onChange={ ( { selectedItem } ) => {
218+
console.debug( selectedItem );
219+
// @todo style is missing from the object
220+
onChange( selectedItem.style );
221+
}
217222
}
218223
/>
219224
)

packages/block-editor/src/components/global-styles/typography-panel.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ export default function TypographyPanel( {
219219
fontStyle: newFontStyle,
220220
fontWeight: newFontWeight,
221221
} ) => {
222+
console.debug(fontStyle);
223+
console.debug(fontWeight);
222224
onChange( {
223225
...value,
224226
typography: {

packages/components/src/custom-select-control-v2/legacy-component/index.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
3030
// Forward props + store from v2 implementation
3131
const store = Ariakit.useSelectStore( {
3232
async setValue( nextValue ) {
33+
console.debug('nextValue: ', nextValue);
3334
if ( ! onChange ) return;
3435

3536
// Executes the logic in a microtask after the popup is closed.
3637
// This is simply to ensure the isOpen state matches that in Downshift.
3738
await Promise.resolve();
3839
const state = store.getState();
3940

41+
console.debug(state);
42+
4043
const changeObject = {
4144
highlightedIndex: state.renderedItems.findIndex(
4245
( item ) => item.value === nextValue
@@ -45,7 +48,9 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
4548
isOpen: state.open,
4649
selectedItem: {
4750
name: nextValue as string,
48-
key: nextValue as string,
51+
key: nextValue as string, // @todo Why key and name have the same value?
52+
// @todo this structure is not compatible with the one from FontAppearanceControl, which
53+
// expects an `style` attribute. Probably something to be fixed in FontAppearanceControl? Or am I missing something here?
4954
},
5055
type: '',
5156
};
@@ -129,3 +134,14 @@ function CustomSelectControl( props: LegacyCustomSelectProps ) {
129134
}
130135

131136
export default CustomSelectControl;
137+
138+
// for backwards compatibility
139+
export function StableCustomSelectControl( props: LegacyCustomSelectProps ) {
140+
console.debug(props);
141+
return (
142+
<CustomSelectControl
143+
{ ...props }
144+
__experimentalShowSelectedHint={ false }
145+
/>
146+
);
147+
}

packages/components/src/custom-select-control-v2/stories/default.story.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useState } from '@wordpress/element';
1414
import CustomSelectControlV2 from '..';
1515

1616
const meta: Meta< typeof CustomSelectControlV2 > = {
17-
title: 'Components (Experimental)/CustomSelectControl v2/Default',
17+
title: 'Components/CustomSelectControl v2/Default',
1818
component: CustomSelectControlV2,
1919
subcomponents: {
2020
// @ts-expect-error - See https://github.com/storybookjs/storybook/issues/23170

packages/components/src/custom-select-control-v2/stories/legacy.story.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import CustomSelectControl from '../legacy-component';
1515
import * as V1Story from '../../custom-select-control/stories/index.story';
1616

1717
const meta: Meta< typeof CustomSelectControl > = {
18-
title: 'Components (Experimental)/CustomSelectControl v2/Legacy',
18+
title: 'Components/CustomSelectControl v2/Legacy',
1919
component: CustomSelectControl,
2020
argTypes: {
2121
onChange: { control: { type: null } },

packages/components/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ export {
7878
ConfirmDialog as __experimentalConfirmDialog,
7979
ConfirmDialog,
8080
} from './confirm-dialog';
81-
export { StableCustomSelectControl as CustomSelectControl } from './custom-select-control';
81+
export { StableCustomSelectControl as CustomSelectControl } from './custom-select-control-v2/legacy-component';
82+
export { default as CustomSelectControlV2 } from './custom-select-control-v2';
8283
export { default as Dashicon } from './dashicon';
8384
export { default as DateTimePicker, DatePicker, TimePicker } from './date-time';
8485
export { default as __experimentalDimensionControl } from './dimension-control';

storybook/manager-head.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'bordercontrol',
88
'boxcontrol',
99
'confirmdialog',
10+
'customselectcontrol-v2',
1011
];
1112
const REDIRECTS = [
1213
{

0 commit comments

Comments
 (0)