Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ function AuthorControl( { value, onChange } ) {
suggestions={ authorsInfo.names }
onChange={ onAuthorChange }
help=""
__next40pxDefaultSize
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export default function FormatControls( { onChange, query: { format } } ) {
} }
help=""
__experimentalExpandOnFocus
__next40pxDefaultSize
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ function ParentControl( { parents, postType, onChange } ) {
};
return (
<FormTokenField
__next40pxDefaultSize
label={ __( 'Parents' ) }
value={ value }
onInputChange={ debouncedSearch }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ function TaxonomyItem( {
displayTransform={ decodeEntities }
onChange={ onTermsChange }
help=""
__next40pxDefaultSize
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ export default function IncludeControl( {

return (
<FormTokenField
__next40pxDefaultSize
value={ value }
onInputChange={ debouncedSearch }
suggestions={ suggestions }
Expand Down
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- `ComboboxControl` ([#79636](https://github.com/WordPress/gutenberg/pull/79636)).
- `FontSizePicker` ([#79481](https://github.com/WordPress/gutenberg/pull/79481))
- `FormFileUpload` ([#79655](https://github.com/WordPress/gutenberg/pull/79655))
- `FormTokenField` ([#79720](https://github.com/WordPress/gutenberg/pull/79720))
- `RangeControl` ([#79590](https://github.com/WordPress/gutenberg/pull/79590))
- `Radio` ([#79657](https://github.com/WordPress/gutenberg/pull/79657))
- `ToggleGroupControl` ([#79656](https://github.com/WordPress/gutenberg/pull/79656))
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/form-token-field/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ The `value` property is handled in a manner similar to controlled form component
- `__experimentalShowHowTo` - **Deprecated.** Use the `help` prop instead. The `help` prop now defaults to the previous how-to text; if you were passing `__experimentalShowHowTo={ false }` to hide it, pass an empty string to `help` instead.
- `__experimentalValidateInput` - If passed, all introduced values will be validated before being added as tokens.
- `__experimentalAutoSelectFirstMatch` - If true, the select the first matching suggestion when the user presses the Enter key (or space when tokenizeOnSpace is true).
- `__next40pxDefaultSize` - Start opting into the larger default height that will become the default size in a future version.
- `tokenizeOnBlur` - If true, add any incompleteTokenValue as a new token when the field loses focus.

## Usage
Expand All @@ -85,7 +84,6 @@ const MyFormTokenField = () => {

return (
<FormTokenField
__next40pxDefaultSize
value={ selectedContinents }
suggestions={ continents }
onChange={ ( tokens ) => setSelectedContinents( tokens ) }
Expand Down
13 changes: 1 addition & 12 deletions packages/components/src/form-token-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ import {
StyledHelp,
StyledLabel,
} from '../base-control/styles/base-control-styles';
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 @@ -78,17 +76,10 @@ export function FormTokenField( props: FormTokenFieldProps ) {
__experimentalExpandOnFocus = false,
__experimentalValidateInput = () => true,
__experimentalShowHowTo,
__next40pxDefaultSize = false,
__experimentalAutoSelectFirstMatch = false,
tokenizeOnBlur = false,
help,
} = useDeprecated36pxDefaultSizeProp< FormTokenFieldProps >( props );

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

const defaultHelp = tokenizeOnSpace
? __( 'Separate with commas, spaces, or the Enter key.' )
Expand Down Expand Up @@ -840,8 +831,6 @@ export function FormTokenField( props: FormTokenFieldProps ) {
align="center"
gap={ 1 }
wrap
__next40pxDefaultSize={ __next40pxDefaultSize }
hasTokens={ !! value.length }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed this hasTokens thing as well since it was only for compatibility styling.

>
{ renderTokensAndInput() }
</TokensAndInputWrapperFlex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const DefaultTemplate: StoryFn< typeof FormTokenField > = ( { ...args } ) => {

return (
<FormTokenField
__next40pxDefaultSize
{ ...args }
value={ selectedContinents }
onChange={ ( tokens ) => setSelectedContinents( tokens ) }
Expand All @@ -71,7 +70,6 @@ export const Default: StoryFn< typeof FormTokenField > = DefaultTemplate.bind(
Default.args = {
label: 'Type a continent',
suggestions: continents,
__next40pxDefaultSize: true,
};

export const Async: StoryFn< typeof FormTokenField > = ( {
Expand All @@ -98,7 +96,6 @@ export const Async: StoryFn< typeof FormTokenField > = ( {

return (
<FormTokenField
__next40pxDefaultSize
{ ...args }
value={ selectedContinents }
suggestions={ availableContinents }
Expand All @@ -110,7 +107,6 @@ export const Async: StoryFn< typeof FormTokenField > = ( {
Async.args = {
label: 'Type a continent',
suggestions: continents,
__next40pxDefaultSize: true,
};

export const DropdownSelector: StoryFn< typeof FormTokenField > =
Expand Down
19 changes: 0 additions & 19 deletions packages/components/src/form-token-field/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,14 @@
* External dependencies
*/
import styled from '@emotion/styled';
import { css } from '@emotion/react';

/**
* Internal dependencies
*/
import { Flex } from '../flex';
import { space } from '../utils/space';
import { boxSizingReset } from '../utils';

type TokensAndInputWrapperProps = {
__next40pxDefaultSize: boolean;
hasTokens: boolean;
};

const deprecatedPaddings = ( {
__next40pxDefaultSize,
hasTokens,
}: TokensAndInputWrapperProps ) =>
! __next40pxDefaultSize &&
css`
padding-top: ${ space( hasTokens ? 1 : 0.5 ) };
padding-bottom: ${ space( hasTokens ? 1 : 0.5 ) };
`;

export const TokensAndInputWrapperFlex = styled( Flex )`
padding: 7px;
${ boxSizingReset }

${ deprecatedPaddings }
`;
6 changes: 1 addition & 5 deletions packages/components/src/form-token-field/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ import { logged } from '@wordpress/deprecated';
/**
* Internal dependencies
*/
import _FormTokenField from '../';

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

const FormTokenFieldWithState = ( {
onChange,
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/form-token-field/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ export interface FormTokenFieldProps
* Start opting into the larger default height that will become the
* default size in a future version.
*
* @default false
* @deprecated Default behavior since WordPress 7.1. Prop can be safely removed.
* @ignore
*/
__next40pxDefaultSize?: boolean;
/**
Expand Down
1 change: 0 additions & 1 deletion packages/components/src/query-controls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export function QueryControls( {
props.categorySuggestions &&
props.onCategoryChange && (
<FormTokenField
__next40pxDefaultSize
key="query-controls-categories-select"
label={ __( 'Categories' ) }
value={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ const UnforwardedValidatedFormTokenField = (
customValidity,
markWhenOptional,
...restProps
}: Omit<
React.ComponentProps< typeof FormTokenField >,
'__next40pxDefaultSize'
> &
ValidatedControlProps,
}: React.ComponentProps< typeof FormTokenField > & ValidatedControlProps,
forwardedRef: React.ForwardedRef< HTMLDivElement >
) => {
const validityTargetRef = useRef< HTMLInputElement >( null );
Expand All @@ -36,7 +32,7 @@ const UnforwardedValidatedFormTokenField = (
customValidity={ customValidity }
getValidityTarget={ () => validityTargetRef.current }
>
<FormTokenField __next40pxDefaultSize { ...restProps } />
<FormTokenField { ...restProps } />
</ControlWithError>
<input
className="components-validated-control__error-delegate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ export function FlatTermSelector( { slug } ) {
return (
<Stack direction="column" gap="lg">
<FormTokenField
__next40pxDefaultSize
value={ values }
suggestions={ suggestions }
onChange={ onChange }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The following components are checked by this rule:

- Button
- CustomSelectControl
- FormTokenField
- InputControl
- NumberControl
- SelectControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ ruleTester.run( 'components-no-missing-40px-size-prop', rule, {
code: `
import {
CustomSelectControl,
FormTokenField,
InputControl,
NumberControl,
RangeControl,
Expand All @@ -107,7 +106,7 @@ ruleTester.run( 'components-no-missing-40px-size-prop', rule, {
} from '@wordpress/components';
<>
<CustomSelectControl __next40pxDefaultSize />
<FormTokenField __next40pxDefaultSize />
<FormTokenField />
<InputControl __next40pxDefaultSize />
<NumberControl __next40pxDefaultSize />
<RangeControl />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const COMPONENTS_REQUIRING_40PX = new Set( [
'Button',
'ClipboardButton',
'CustomSelectControl',
'FormTokenField',
'IconButton',
'InputControl',
'NumberControl',
Expand Down
1 change: 0 additions & 1 deletion packages/patterns/src/components/category-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export default function CategorySelector( {
label={ __( 'Categories' ) }
tokenizeOnBlur
__experimentalExpandOnFocus
__next40pxDefaultSize
/>
);
}
1 change: 1 addition & 0 deletions tools/eslint/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const restrictedSyntax = [
'FontFamilyControl',
'FontSizePicker',
'FormFileUpload',
'FormTokenField',
'LetterSpacingControl',
'LineHeightControl',
'QueryControls',
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint/suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@
},
"packages/components/src/form-token-field/styles.ts": {
"no-restricted-imports": {
"count": 2
"count": 1
}
},
"packages/components/src/grid/hook.ts": {
Expand Down
Loading