Skip to content

Commit

Permalink
Changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Sep 5, 2023
1 parent 15845cf commit f321e53
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/form-token-field/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ The `value` property is handled in a manner similar to controlled form component
- `__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).
- `__nextHasNoMarginBottom` - Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.5. (The prop can be safely removed once this happens.)
- `tokenizeOnBlur` - If true adds any incompleteTokenValue as a new token when field loses focus.
- `tokenizeOnBlur` - If true, add any incompleteTokenValue as a new token when the field loses focus.

## Usage

Expand Down
9 changes: 2 additions & 7 deletions packages/components/src/form-token-field/test/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
within,
getDefaultNormalizer,
waitFor,
act,
} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import type { ComponentProps } from 'react';
Expand Down Expand Up @@ -219,9 +218,7 @@ describe( 'FormTokenField', () => {

// Add 'grapefruit' token by typing it and check blur of field does not tokenize it.
await user.type( input, 'grapefruit' );
act( () => {
input.blur();
} );
await user.click( document.body );
expect( onChangeSpy ).toHaveBeenCalledTimes( 0 );
expectTokensNotToBeInTheDocument( [ 'grapefruit' ] );

Expand All @@ -236,9 +233,7 @@ describe( 'FormTokenField', () => {
// Add 'grapefruit' token by typing it and check blur of field tokenizes it.
await user.type( input, 'grapefruit' );

act( () => {
input.blur();
} );
await user.click( document.body );
expect( onChangeSpy ).toHaveBeenNthCalledWith( 1, [
'grapefruit',
] );
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/form-token-field/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export interface FormTokenFieldProps
*/
__nextHasNoMarginBottom?: boolean;
/**
* If true add any incompleteTokenValue as a new token.
* If true, add any incompleteTokenValue as a new token when the field loses focus.
*
* @default false
*/
Expand Down

0 comments on commit f321e53

Please sign in to comment.