Skip to content

Commit

Permalink
Components: Do not render FormTokenField label when not defined (#61336)
Browse files Browse the repository at this point in the history
Co-authored-by: retrofox <retrofox@git.wordpress.org>
Co-authored-by: alexstine <alexstine@git.wordpress.org>
  • Loading branch information
3 people authored May 8, 2024
1 parent ebcf8d0 commit 60d2269
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
- Replaced `classnames` package with the faster and smaller `clsx` package ([#61138](https://github.com/WordPress/gutenberg/pull/61138)).

### Enhancements

- `PaletteEdit`: Use consistent spacing and metrics. ([#61368](https://github.com/WordPress/gutenberg/pull/61368)).
- `FormTokenField`: Hide label when not defined ([#61336](https://github.com/WordPress/gutenberg/pull/61336)).

## 27.5.0 (2024-05-02)

Expand Down
14 changes: 8 additions & 6 deletions packages/components/src/form-token-field/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,14 @@ export function FormTokenField( props: FormTokenFieldProps ) {
/* eslint-disable jsx-a11y/no-static-element-interactions */
return (
<div { ...tokenFieldProps }>
<StyledLabel
htmlFor={ `components-form-token-input-${ instanceId }` }
className="components-form-token-field__label"
>
{ label }
</StyledLabel>
{ label && (
<StyledLabel
htmlFor={ `components-form-token-input-${ instanceId }` }
className="components-form-token-field__label"
>
{ label }
</StyledLabel>
) }
<div
ref={ tokensAndInput }
className={ classes }
Expand Down

0 comments on commit 60d2269

Please sign in to comment.