Skip to content

Commit

Permalink
FormTokenField: Deprecate 36px default size (#67454)
Browse files Browse the repository at this point in the history
* Update FormTokenField Component to use default 40px size and added 36px deprecation warning

* Update the changelog to add deprecation PR for the FormTokenField

* Add __next40pxDefaultSize to async story for FormTokenField

Co-authored-by: hbhalodia <[email protected]>
Co-authored-by: mirka <[email protected]>
  • Loading branch information
3 people authored and michalczaplinski committed Dec 5, 2024
1 parent 92ad471 commit ef7b9c6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
- `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)).
- `FormFileUpload`: Deprecate 36px default size ([#67438](https://github.com/WordPress/gutenberg/pull/67438)).
- `FormTokenField`: Deprecate 36px default size ([#67454](https://github.com/WordPress/gutenberg/pull/67454)).


### Enhancements

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/form-token-field/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const MyFormTokenField = () => {

return (
<FormTokenField
__next40pxDefaultSize
value={ selectedContinents }
suggestions={ continents }
onChange={ ( tokens ) => setSelectedContinents( tokens ) }
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/form-token-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import { Spacer } from '../spacer';
import { useDeprecated36pxDefaultSizeProp } from '../utils/use-deprecated-props';
import { withIgnoreIMEEvents } from '../utils/with-ignore-ime-events';
import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size';

const identity = ( value: string ) => value;

Expand Down Expand Up @@ -86,6 +87,12 @@ export function FormTokenField( props: FormTokenFieldProps ) {
} );
}

maybeWarnDeprecated36pxSize( {
componentName: 'FormTokenField',
size: undefined,
__next40pxDefaultSize,
} );

const instanceId = useInstanceId( FormTokenField );

// We reset to these initial values again in the onBlur
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Default.args = {
label: 'Type a continent',
suggestions: continents,
__nextHasNoMarginBottom: true,
__next40pxDefaultSize: true,
};

export const Async: StoryFn< typeof FormTokenField > = ( {
Expand Down Expand Up @@ -102,6 +103,7 @@ Async.args = {
label: 'Type a continent',
suggestions: continents,
__nextHasNoMarginBottom: true,
__next40pxDefaultSize: true,
};

export const DropdownSelector: StoryFn< typeof FormTokenField > =
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/form-token-field/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import FormTokenField from '../';
import _FormTokenField from '../';

const FormTokenField = ( props: ComponentProps< typeof _FormTokenField > ) => (
<_FormTokenField __next40pxDefaultSize { ...props } />
);

const FormTokenFieldWithState = ( {
onChange,
Expand Down

0 comments on commit ef7b9c6

Please sign in to comment.