diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 5e73e4319a1ba0..a05ea9095074ad 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -25,6 +25,7 @@ ### Experimental - `Tabs`: implement new `tabId` prop ([#56883](https://github.com/WordPress/gutenberg/pull/56883)). +- `CustomSelect`: add `WordPressComponentsProps` for more flexibility ([#56998](https://github.com/WordPress/gutenberg/pull/56998)) ### Experimental diff --git a/packages/components/src/custom-select-control-v2/index.tsx b/packages/components/src/custom-select-control-v2/index.tsx index 88231078fa8d56..614f52105513f4 100644 --- a/packages/components/src/custom-select-control-v2/index.tsx +++ b/packages/components/src/custom-select-control-v2/index.tsx @@ -18,6 +18,7 @@ import type { CustomSelectItemProps, CustomSelectContext as CustomSelectContextType, } from './types'; +import type { WordPressComponentProps } from '../context'; export const CustomSelectContext = createContext< CustomSelectContextType >( undefined ); @@ -41,17 +42,16 @@ function defaultRenderSelectedValue( value: CustomSelectProps[ 'value' ] ) { return value; } -export function CustomSelect( props: CustomSelectProps ) { - const { - children, - defaultValue, - label, - onChange, - size = 'default', - value, - renderSelectedValue = defaultRenderSelectedValue, - } = props; - +export function CustomSelect( { + children, + defaultValue, + label, + onChange, + size = 'default', + value, + renderSelectedValue = defaultRenderSelectedValue, + ...props +}: WordPressComponentProps< CustomSelectProps, 'button', false > ) { const store = Ariakit.useSelectStore( { setValue: ( nextValue ) => onChange?.( nextValue ), defaultValue, @@ -66,6 +66,7 @@ export function CustomSelect( props: CustomSelectProps ) { { label } ) { const customSelectContext = useContext( CustomSelectContext ); return (