From 71734637c2f764eb01f83f0b79cc312cbcdc1268 Mon Sep 17 00:00:00 2001 From: brookewp Date: Tue, 12 Dec 2023 17:37:20 -0800 Subject: [PATCH 1/3] CustomSelectControl v2: Add WordPressComponentsProps --- packages/components/src/custom-select-control-v2/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/src/custom-select-control-v2/index.tsx b/packages/components/src/custom-select-control-v2/index.tsx index 88231078fa8d5..6b61a8b0209aa 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 ); @@ -85,7 +86,7 @@ export function CustomSelect( props: CustomSelectProps ) { export function CustomSelectItem( { children, ...props -}: CustomSelectItemProps ) { +}: WordPressComponentProps< CustomSelectItemProps, 'div', false > ) { const customSelectContext = useContext( CustomSelectContext ); return ( Date: Tue, 12 Dec 2023 18:16:19 -0800 Subject: [PATCH 2/3] Add WordPressComponentProps as button to CustomSelect --- .../src/custom-select-control-v2/index.tsx | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/components/src/custom-select-control-v2/index.tsx b/packages/components/src/custom-select-control-v2/index.tsx index 6b61a8b0209aa..614f52105513f 100644 --- a/packages/components/src/custom-select-control-v2/index.tsx +++ b/packages/components/src/custom-select-control-v2/index.tsx @@ -42,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, @@ -67,6 +66,7 @@ export function CustomSelect( props: CustomSelectProps ) { { label } Date: Wed, 13 Dec 2023 10:27:14 -0800 Subject: [PATCH 3/3] Update changelog --- packages/components/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 5e73e4319a1ba..a05ea9095074a 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