Skip to content

Commit

Permalink
CustomSelectControl: Deprecate 36px default size (#67441)
Browse files Browse the repository at this point in the history
* CustomSelectControl: Deprecate 36px default size

* Add changelog

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
3 people authored Dec 2, 2024
1 parent 232d14f commit b61f913
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export default function FontAppearanceControl( props ) {
{ ...otherProps }
className="components-font-appearance-control"
__next40pxDefaultSize={ __next40pxDefaultSize }
__shouldNotWarnDeprecated36pxSize
label={ label }
describedBy={ getDescribedBy() }
options={ selectOptions }
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/font-family/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function FontFamilyControl( {
return (
<CustomSelectControl
__next40pxDefaultSize={ __next40pxDefaultSize }
__shouldNotWarnDeprecated36pxSize
label={ __( 'Font' ) }
value={ value }
onChange={ ( { selectedItem } ) => onChange( selectedItem.key ) }
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- `BoxControl`: Passive deprecate `onMouseOver`/`onMouseOut`. Pass to the `inputProps` prop instead ([#67332](https://github.com/WordPress/gutenberg/pull/67332)).
- `BoxControl`: Deprecate 36px default size ([#66704](https://github.com/WordPress/gutenberg/pull/66704)).
- `CustomSelectControl`: Deprecate 36px default size ([#67441](https://github.com/WordPress/gutenberg/pull/67441)).
- `NumberControl`: Deprecate 36px default size ([#66730](https://github.com/WordPress/gutenberg/pull/66730)).
- `UnitControl`: Deprecate 36px default size ([#66791](https://github.com/WordPress/gutenberg/pull/66791)).

Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/custom-select-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function MyCustomSelectControl() {
const [ , setFontSize ] = useState();
return (
<CustomSelectControl
__next40pxDefaultSize
label="Font Size"
options={ options }
onChange={ ( { selectedItem } ) => setFontSize( selectedItem ) }
Expand All @@ -52,6 +53,7 @@ function MyControlledCustomSelectControl() {
const [ fontSize, setFontSize ] = useState( options[ 0 ] );
return (
<CustomSelectControl
__next40pxDefaultSize
label="Font Size"
options={ options }
onChange={ ( { selectedItem } ) => setFontSize( selectedItem ) }
Expand Down
9 changes: 9 additions & 0 deletions packages/components/src/custom-select-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import CustomSelectItem from '../custom-select-control-v2/item';
import * as Styled from '../custom-select-control-v2/styles';
import type { CustomSelectProps, CustomSelectOption } from './types';
import { VisuallyHidden } from '../visually-hidden';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

function useDeprecatedProps< T extends CustomSelectOption >( {
__experimentalShowSelectedHint,
Expand Down Expand Up @@ -56,6 +57,7 @@ function CustomSelectControl< T extends CustomSelectOption >(
) {
const {
__next40pxDefaultSize = false,
__shouldNotWarnDeprecated36pxSize,
describedBy,
options,
onChange,
Expand All @@ -66,6 +68,13 @@ function CustomSelectControl< T extends CustomSelectOption >(
...restProps
} = useDeprecatedProps( props );

maybeWarnDeprecated36pxSize( {
componentName: 'CustomSelectControl',
__next40pxDefaultSize,
size,
__shouldNotWarnDeprecated36pxSize,
} );

const descriptionId = useInstanceId(
CustomSelectControl,
'custom-select-control__description'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const Template: StoryFn< typeof CustomSelectControl > = ( props ) => {

export const Default = Template.bind( {} );
Default.args = {
__next40pxDefaultSize: true,
label: 'Label',
options: [
{
Expand Down
22 changes: 13 additions & 9 deletions packages/components/src/custom-select-control/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import UncontrolledCustomSelectControl from '..';
import _CustomSelectControl from '..';

const UncontrolledCustomSelectControl = (
props: React.ComponentProps< typeof _CustomSelectControl >
) => <_CustomSelectControl __next40pxDefaultSize { ...props } />;

const customClassName = 'amber-skies';
const customStyles = {
Expand Down Expand Up @@ -716,7 +720,7 @@ describe( 'Type checking', () => {

const onChange = (): void => {};

<UncontrolledCustomSelectControl
<_CustomSelectControl
label="Label"
options={ options }
value={ {
Expand All @@ -726,7 +730,7 @@ describe( 'Type checking', () => {
onChange={ onChange }
/>;

<UncontrolledCustomSelectControl
<_CustomSelectControl
label="Label"
options={ options }
value={ {
Expand All @@ -736,7 +740,7 @@ describe( 'Type checking', () => {
onChange={ onChange }
/>;

<UncontrolledCustomSelectControl
<_CustomSelectControl
label="Label"
options={ options }
value={ {
Expand All @@ -748,7 +752,7 @@ describe( 'Type checking', () => {
onChange={ onChange }
/>;

<UncontrolledCustomSelectControl
<_CustomSelectControl
label="Label"
options={ options }
value={ {
Expand All @@ -764,7 +768,7 @@ describe( 'Type checking', () => {
}
/>;

<UncontrolledCustomSelectControl
<_CustomSelectControl
label="Label"
options={ optionsReadOnly }
value={ {
Expand All @@ -774,7 +778,7 @@ describe( 'Type checking', () => {
onChange={ onChange }
/>;

<UncontrolledCustomSelectControl
<_CustomSelectControl
label="Label"
options={ optionsReadOnly }
value={ {
Expand All @@ -785,7 +789,7 @@ describe( 'Type checking', () => {
onChange={ onChange }
/>;

<UncontrolledCustomSelectControl
<_CustomSelectControl
label="Label"
options={ optionsReadOnly }
value={ {
Expand All @@ -797,7 +801,7 @@ describe( 'Type checking', () => {
onChange={ onChange }
/>;

<UncontrolledCustomSelectControl
<_CustomSelectControl
label="Label"
options={ optionsReadOnly }
value={ {
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/custom-select-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,11 @@ export type CustomSelectProps< T extends CustomSelectOption > = {
* @default false
*/
__next40pxDefaultSize?: boolean;
/**
* Do not throw a warning for the deprecated 36px default size.
* For internal components of other components that already throw the warning.
*
* @ignore
*/
__shouldNotWarnDeprecated36pxSize?: boolean;
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const FontSizePickerSelect = ( props: FontSizePickerSelectProps ) => {
return (
<CustomSelectControl
__next40pxDefaultSize={ __next40pxDefaultSize }
__shouldNotWarnDeprecated36pxSize
className="components-font-size-picker__select"
label={ __( 'Font size' ) }
hideLabelFromVision
Expand Down

1 comment on commit b61f913

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in b61f913.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12124763736
📝 Reported issues:

Please sign in to comment.