Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combobox, FormTokenField: show message when no matches found #66142

1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

- `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))
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this also affects the FormTokenField component when the __experimentalExpandOnFocus prop is enabled.


## 28.9.0 (2024-10-03)

Expand Down
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">
Copy link
Member

Choose a reason for hiding this comment

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

Were you planning on styling the is-empty modifier? I'm thinking we at least need to move the cursor style:

	&:not(.is-empty) {
		cursor: pointer;
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the class is more of placeholder so that where the component is used the user can easily overide the styling with is-empty class. But your suggestion here make sense, I'll add it

Copy link
Contributor

@ciampo ciampo Oct 18, 2024

Choose a reason for hiding this comment

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

where the component is used the user can easily overide the styling with is-empty class.

That is something that we actively discourage — internal classnames are not public APIs and should not be considered as such.

Please do not use the .is-empty classname as a way to apply style overrides.

{ __( 'No items found' ) }
</li>
) }
</ul>
);
}
Expand Down
Loading