Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectControl: Deprecate 36px default size #66732

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/select-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const MySelectControl = () => {

return (
<SelectControl
__next40pxDefaultSize
label="Size"
value={ size }
options={ [
Expand Down Expand Up @@ -115,6 +116,7 @@ Render a user interface to select multiple users from a list.
{ value: 'c', label: 'User c' },
] }
__nextHasNoMarginBottom
__next40pxDefaultSize
/>
```

Expand All @@ -130,6 +132,7 @@ const [ item, setItem ] = useState( '' );
value={ item } // e.g: value = 'a'
onChange={ ( selection ) => { setItem( selection ) } }
__nextHasNoMarginBottom
__next40pxDefaultSize
>
<optgroup label="Theropods">
<option value="Tyrannosaurus">Tyrannosaurus</option>
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/select-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const SelectControlWithState: StoryFn< typeof SelectControl > = ( props ) => {

export const Default = SelectControlWithState.bind( {} );
Default.args = {
__next40pxDefaultSize: true,
__nextHasNoMarginBottom: true,
label: 'Label',
options: [
Expand Down
Loading