Skip to content

Commit

Permalink
Clean up props
Browse files Browse the repository at this point in the history
  • Loading branch information
brookewp committed Jan 26, 2024
1 parent c6665c8 commit 4d6819b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ const UnconnectedCustomSelectButton = (
>
) => {
const {
defaultValue,
renderSelectedValue,
onChange,
size = 'default',
store,
value,
...restProps
} = useContextSystem( props, 'CustomSelectControlButton' );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import _CustomSelect from '../custom-select';
import type { CustomSelectProps } from '../types';

function _NewCustomSelect( props: CustomSelectProps ) {
const { defaultValue, onChange, value, ...restProps } = props;
const { defaultValue, onSelectionChange, value, ...restProps } = props;
// Forward props + store from v2 implementation
const store = Ariakit.useSelectStore( {
setValue: ( nextValue ) => onChange?.( nextValue ),
setValue: ( nextValue ) => onSelectionChange?.( nextValue ),
defaultValue,
value,
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as Ariakit from '@ariakit/react';
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
Expand All @@ -21,7 +20,6 @@ function _LegacyCustomSelect( props: LegacyCustomSelectProps ) {
const {
__experimentalShowSelectedHint,
__next40pxDefaultSize = false,
__nextUnconstrainedWidth,
options,
onChange,
size = 'default',
Expand Down Expand Up @@ -81,16 +79,6 @@ function _LegacyCustomSelect( props: LegacyCustomSelectProps ) {
}
);

if ( __nextUnconstrainedWidth ) {
deprecated(
'Constrained width styles for wp.components.CustomSelectControl',
{
hint: 'This behaviour is now built-in.',
since: '6.4',
}
);
}

const renderSelectedValueHint = () => {
const { value: currentValue } = store.getState();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const ControlledTemplate: StoryFn< typeof NewCustomSelect > = ( props ) => {
return (
<CustomSelect
{ ...props }
onChange={ ( nextValue: string | string[] ) => {
onSelectionChange={ ( nextValue: string | string[] ) => {
setValue( nextValue );
props.onChange?.( nextValue );
props.onSelectionChange?.( nextValue );
} }
value={ value }
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/custom-select-control-v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type CustomSelectButtonProps = {
/**
* A function that receives the new value of the input.
*/
onChange?: ( newValue: string | string[] ) => void;
onSelectionChange?: ( newValue: string | string[] ) => void;
/**
* Can be used to render select UI with custom styled values.
*/
Expand Down

0 comments on commit 4d6819b

Please sign in to comment.