Open ciampo opened 1 month ago
Copying some feedback shared by @jarekmorawski
Design-wise, I'd prefer to stick to the form token field because it's a widely used pattern that most users are accustomed to. It supports multi-select and search. There are ways we'd make it smarter for everyone's benefit:
- Make the token component support non-text elements, like images
- Display handles and make it possible to reorder tokens by drag & drop
- Support error and loading states
- Make tokens optionally dismissible
- Make it possible to search by label, id, slug, SKU, author, and other meta-data
- Display secondary meta-data when two tokens with the same label are added, e.g., ID or Slug
Some items from my wishlist are based on my work on the FlatTermSelector
component.
{ value: id, label: name }
). Handy when working with items from DB. Related: #62533.@Mamaduka
Ability to display explicit action for creating items, currently triggered by comma or Enter key.
Interesting point — it would be great if you could gather examples of this pattern in existing UI libraries or products across the web.
Allow objects as values
Since the new version of the component will likely be a compound component (ie. exposing sub components like, ie., FormTokenField.Item
), we will likely move away from passing an array of strings anyway. The new components will definitely allow showing a label that is different from the underlying ID, and consumers of the component will be able to decide the value
passed to each Item
subcomponent
@diegohaz , do you have suggestions on how would ariakit
support a use case similar to this component, likely building on top of Combobox
?
@diegohaz , do you have suggestions on how would
ariakit
support a use case similar to this component, likely building on top ofCombobox
?
There's an experimental Tag
module that can be combined with Combobox
: https://ariakit.org/examples/tag-combobox
Is that what you mean?
@ciampo, while not exactly the same, the editor already has a similar example in the Link Control component. See the screenshot.
@diegohaz, I was (and am) really excited when you showcased Tags + Combobox on Twitter.
Tag + Combobox looks fantastic.
Display handles and make it possible to reorder tokens by drag & drop
I'm still not sure about this. Seems like it would add a lot of complexity? How would you re-order as a keyboard user?
A few additional issues that have come up historically and could be of interest for the round of feedback:
How would you re-order as a keyboard user?
One solution would be to let users use the arrow keys while holding Shift
. Or, we could let users press Enter
or Space
when a token is active to enter a 'grabbed' state (more info).
Alternatively, if we aimed to follow accessibility guidelines to a dot, we'd add a Reorder
button that lets users rearrange items using the keyboard when activated. We'd only display the handles when the reordering mode is active.
Context
As we're slowly starting to roll out new versions of existing components, we want to start gathering feedback on what changes, improvements, and new features we'd like to see applied to such components.
While we initially focused on
Tooltip
(shipped),Tabs
(almost ready), andDropdownMenu
(still WIP), we think that the next batch of components that we'll focus on is going to beCustomSelectControl
,ComboboxControl
andFormTokenField
.We see these three components as related:
CustomSelectControl
is the first component in the group that we'll focus on, since it is the simplest of the three;ComoboxControl
will come after, since it kind of builds onCustomSelectControl
and adds a text input to search through the options;FormTokenField
will be the last component of the group, as it's the most complex, and kinda builds on top ofComboboxControl
, adding the token "chips".Feedback
I will update this section as we gather feedback.
CustomSelectControl
V2 withrenderSelectedValue
cc @WordPress/gutenberg-components @WordPress/gutenberg-design