From 2e06c244d516d15dbadd66a79b0d447a750d0c5b Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Tue, 5 Nov 2024 09:18:57 +0530 Subject: [PATCH 1/2] Fix add the deprecation for the select control component --- packages/components/src/select-control/README.md | 3 +++ packages/components/src/select-control/index.tsx | 7 +++++++ .../components/src/select-control/stories/index.story.tsx | 1 + 3 files changed, 11 insertions(+) diff --git a/packages/components/src/select-control/README.md b/packages/components/src/select-control/README.md index c240243408fab3..7430ccbf810e99 100644 --- a/packages/components/src/select-control/README.md +++ b/packages/components/src/select-control/README.md @@ -84,6 +84,7 @@ const MySelectControl = () => { return ( ``` @@ -130,6 +132,7 @@ const [ item, setItem ] = useState( '' ); value={ item } // e.g: value = 'a' onChange={ ( selection ) => { setItem( selection ) } } __nextHasNoMarginBottom + __next40pxDefaultSize > diff --git a/packages/components/src/select-control/index.tsx b/packages/components/src/select-control/index.tsx index 3686661b8a58dc..dfc87fc1d3435a 100644 --- a/packages/components/src/select-control/index.tsx +++ b/packages/components/src/select-control/index.tsx @@ -18,6 +18,7 @@ import type { WordPressComponentProps } from '../context'; import type { SelectControlProps } from './types'; import SelectControlChevronDown from './chevron-down'; import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props'; +import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size'; function useUniqueId( idProp?: string ) { const instanceId = useInstanceId( SelectControl ); @@ -70,6 +71,12 @@ function UnforwardedSelectControl< V extends string >( const id = useUniqueId( idProp ); const helpId = help ? `${ id }__help` : undefined; + maybeWarnDeprecated36pxSize( { + componentName: 'SelectControl', + size, + __next40pxDefaultSize, + } ); + // Disable reason: A select with an onchange throws a warning. if ( ! options?.length && ! children ) { return null; diff --git a/packages/components/src/select-control/stories/index.story.tsx b/packages/components/src/select-control/stories/index.story.tsx index 5e57a4eaecd5ab..4e813521d8a7b1 100644 --- a/packages/components/src/select-control/stories/index.story.tsx +++ b/packages/components/src/select-control/stories/index.story.tsx @@ -64,6 +64,7 @@ const SelectControlWithState: StoryFn< typeof SelectControl > = ( props ) => { export const Default = SelectControlWithState.bind( {} ); Default.args = { + __next40pxDefaultSize: true, __nextHasNoMarginBottom: true, label: 'Label', options: [ From 054a71aa187c7fc5a9b438dc9c1782818337e340 Mon Sep 17 00:00:00 2001 From: hbhalodia Date: Tue, 5 Nov 2024 09:27:33 +0530 Subject: [PATCH 2/2] Add the changelog for the deprecation for 36px default size on SelectControl component --- packages/components/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 93b191bff269d6..8822616186a9d8 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -5,6 +5,7 @@ ### Deprecations - `Radio`: Deprecate 36px default size ([#66572](https://github.com/WordPress/gutenberg/pull/66572)). +- `SelectControl`: Deprecate 36px default size ([#66732](https://github.com/WordPress/gutenberg/pull/66732)). ### Enhancements