Skip to content

Commit

Permalink
Combobox, FormTokenField: show message when no matches found (#66142)
Browse files Browse the repository at this point in the history
Co-authored-by: vykes-mac <vykesmac@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: matt-west <mattwest@git.wordpress.org>
  • Loading branch information
7 people authored Oct 21, 2024
1 parent f99347e commit 6fbca55
Show file tree
Hide file tree
Showing 3 changed files with 12 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 @@ -40,6 +40,8 @@

- `Modal`: Modal dialog small improvement for elementShouldBeHidden ([#65941](https://github.com/WordPress/gutenberg/pull/65941)).
- `Tabs`: revamped vertical orientation styles ([#65387](https://github.com/WordPress/gutenberg/pull/65387)).
- `ComboboxControl`: display `No items found` when there are no matches found ([#66142](https://github.com/WordPress/gutenberg/pull/66142))
- `FormTokenField`: display `No items found` when there are no matches found. This occurs when the `__experimentalExpandOnFocus` prop is enabled ([#66142](https://github.com/WordPress/gutenberg/pull/66142))

## 28.9.0 (2024-10-03)

Expand Down
5 changes: 4 additions & 1 deletion packages/components/src/form-token-field/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
padding: $grid-unit-10 $grid-unit-15;
min-height: $button-size-compact;
margin: 0;
cursor: pointer;
box-sizing: border-box;

&.is-selected {
Expand All @@ -189,4 +188,8 @@
background-color: $components-color-accent-transparent-40;
}
}

&:not(.is-empty) {
cursor: pointer;
}
}
6 changes: 6 additions & 0 deletions packages/components/src/form-token-field/suggestions-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { MouseEventHandler, ReactNode } from 'react';
* WordPress dependencies
*/
import { useRefEffect } from '@wordpress/compose';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand Down Expand Up @@ -156,6 +157,11 @@ export function SuggestionsList<
);
/* eslint-enable jsx-a11y/click-events-have-key-events */
} ) }
{ suggestions.length === 0 && (
<li className="components-form-token-field__suggestion is-empty">
{ __( 'No items found' ) }
</li>
) }
</ul>
);
}
Expand Down

0 comments on commit 6fbca55

Please sign in to comment.