gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Combobox/add custom element when suggestions not found

Open vykes-mac opened this issue 1 year ago • 10 comments

What?

The PR allows the ComboxControl and FormTokenField components to show a message when there are no suggestions matching the input text.

Why?

This PR is more of an enhancement and provides a better user experience when searching the ComboboxControl and FormTokenField components.

How?

Accepts __experimentalRenderNoSuggestionsFound component and displays it when no suggestion is found in the SuggestionsList component.

Testing Instructions

Open Storybook and pick the Components > ComboboxControl component. Search for an item that doesn't exist and you should see No items found state.

Screenshots or screencast

image

vykes-mac avatar Oct 15 '24 19:10 vykes-mac

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: vykes-mac <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: matt-west <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

github-actions[bot] avatar Oct 15 '24 19:10 github-actions[bot]

Thank you for opening this PR!

@WordPress/gutenberg-components , what do we think about adding a similar feature directly to the component (no props) and displaying a more generic message? Something like "No items found".

ciampo avatar Oct 16 '24 09:10 ciampo

@WordPress/gutenberg-components , what do we think about adding a similar feature directly to the component (no props) and displaying a more generic message? Something like "No items found".

Yeah, I think it might be a better experience than what we're doing now (showing nothing):

Screenshot 2024-10-16 at 13 42 03

@WordPress/gutenberg-design any thoughts or preferences?

tyxla avatar Oct 16 '24 10:10 tyxla

Something like "No items found".

Sounds good to me. Any downsides?

jasmussen avatar Oct 16 '24 10:10 jasmussen

Something like "No items found".

Sounds good to me. Any downsides?

Can't think of any. Even that string exists already and will inherit existing translations immediately:

https://github.com/WordPress/gutenberg/blob/683171150bb91c750c717582f736607fafdf1671/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js#L139

tyxla avatar Oct 16 '24 10:10 tyxla

@vykes-mac could you change this PR so that the message is always shown (no extra props needed) and the text reads "No items found" ? Thank you 🙏

ciampo avatar Oct 16 '24 11:10 ciampo

Thanks for implementing this @vykes-mac. 🙌

matt-west avatar Oct 16 '24 13:10 matt-west

@ciampo What if we want to customise the copy that's displayed there? Eg. the list is showing Authors instead of No items found I would like to pass my custom messaging No authors found .

vykes-mac avatar Oct 16 '24 17:10 vykes-mac

@ciampo What if we want to customise the copy that's displayed there? Eg. the list is showing Authors instead of No items found I would like to pass my custom messaging No authors found .

Would "No matches found" be a more generic wording in this case?

To be honest I prefer not adding a prop right now to customize this, as it will naturally be customizable in the planned version 2 of this component, which will be based on Ariakit and more modular.

mirka avatar Oct 16 '24 17:10 mirka

@ciampo What if we want to customise the copy that's displayed there? Eg. the list is showing Authors instead of No items found I would like to pass my custom messaging No authors found .

Would "No matches found" be a more generic wording in this case?

To be honest I prefer not adding a prop right now to customize this, as it will naturally be customizable in the planned version 2 of this component, which will be based on Ariakit and more modular.

@mirka I'll proceed with the No items found found then since translation already exist for the string

vykes-mac avatar Oct 16 '24 19:10 vykes-mac

As a follow-up, can we modify this by allowing a custom component? I think it might help us resolve the first item on this list: https://github.com/WordPress/gutenberg/issues/64086#issuecomment-2258070011.

Mamaduka avatar Oct 22 '24 02:10 Mamaduka

As Lena mentioned above, we'd rather unlock this level of customizability in the v2 of the component, rather than putting in work on the v1 (unless we're talking about a very important feature / urgent hotfix). There's already a lot on our plate and we're trying to prioritise our focus where it's needed the most.

ciampo avatar Oct 22 '24 10:10 ciampo

V2 sounds good 👍

Mamaduka avatar Oct 22 '24 10:10 Mamaduka