-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
New component: ListboxControl #65801
Comments
Thank you for working on this! In the case of listbox widgets, there is no such thing as "checkbox" or "radio" items . Rather, there is only one type of listbox options — and there can be none, one, or multiple selected at the same time. To avoid the confusion with radios and checkboxes, I wonder if we should consider a different visual indicator for the selected items (for example, ariakit uses a tick in their multiple selection combobox example) cc @WordPress/gutenberg-components |
I wonder if we could conceptualize this as a "MenuList", as that'd allow us to, instead of creating a new component, make the existing menu component cover more use cases by making it more open. This mimic the Ariakit structure (see To be clear, what I am proposing is to add the possibility to use our current menu ( @ciampo's suggestion of using a tick is also covered by this. |
Listboxes are more generic and can be the foundation of components like We could share a lot of the styles, though. |
I like the design of both the checkbox and the radio, but - as pointed out by @ciampo and @DaniGuardiola - they both look like there are from different design languages. Another thing is the color blue. I like it. |
Maybe we also should consider |
As mentioned above, if we're sticking with At most, that could be added to places where we support |
On my phone right now so can't check, but I think it's worth looking into the semantics that Ariakit has for MenuList. Wouldn't surprise me if it just used plain listbox semantics. The name of Ariakit components does not always correlate to the corresponding semantics. |
@ciampo I appreciate they are not semantically checkbox or radio items, but isn't it correct that in terms of behavior listboxes can be configured either as single-select (similar to a I suppose I should have noted that the design would not utilise actual checkboxes, they would be elements styled to look like checkboxes. This is a fairly common pattern in design systems; there's a similar example in github issue label assignment UI: |
I'm trying to think what the usage guidelines for this would look like. Specifically, when should one use this Listbox over other similar controls, like: Single-select
Multi-select
I'm not sure you'd need a separate Listbox component unless it is for a feature that is not covered in the alternatives, like making the items sortable (as in #64686). And if the main feature we want to provide is sortability, then it might make more sense to provide it as a lower-level, headless API (e.g. SortableJS) so consumers can add sortability to a broader variety of designs. |
@DaniGuardiola I believe that they apply
@jameskoster I see your point — let me try to rephrase my feedback: "radio" and "checkbox" are concepts that don't apply in the context of a listbox, and I'm afraid that using them even as just visual cues may set the wrong expectation to the user. Basically, we should just pick one style (probably checkbox-like), instead of using both checkbox-like and radio-like
@mirka I am seeing this component as a very low-level component that we can leverage to implement all of the other components that you mentioned? Similarly to Composite` |
Of the components I listed, those that could possibly use this is ComboboxControl/FormTokenField (which will eventually be a unified as ComboboxControlV2) and CustomSelectControlV2. Ariakit Select and Combobox already have their own subcomponents for these things. So in that case, it would be more natural to just share/reuse the styles, not entire components, because Ariakit is already providing them (behavior + semantics). The only reason we would want a standalone Listbox component (styles + behavior + semantics) is if we want to use it independently, or in a non-Ariakit-based component. And I'm struggling to imagine such a use case (aside from the sortable case). |
The example that Jat posted above ( the dataviews filter) could be such a use case? |
I think I would prefer just making CustomSelectControlV2 flexible enough to support that design. Right now, |
Definitely something to consider. We'd also need to make sure we can offer the listbox itself separate from the popover / dropdown part, though, because this UI pattern can also happen: |
Great discussion! I'm so glad we're talking about changes to the select component because it's likely the second most-used component in the admin experience (including screens added by plugins). I don't want to stir the pot too much, but I'd love to see us have just one select component with all the necessary features. Here's my wishlist based on my experience designing admin pages. Most of these features focus on the multi-select variant, but some would also apply to the single-select version. Support for nested groupsThere are many cases where users need to browse items organized in hierarchies. The component should support displaying items not just in groups with individual headings (like in Jay's example), but also in a tree-like view. This would allow users to browse items contained within other items. These groups could be displayed as accordions, enabling users to expand and collapse groups, and to select them with a single click.
Use cases:
"Contained" display modeI agree that the Use cases:
Support for select/deselect allIt would be helpful to allow users to select or deselect all items in the list. Selecting all could be done with a dedicated button at the top of the list (not fixed), while clearing the selection could be handled via an "X" button on the right-hand side of the field. This is a standard feature in many established design systems. Use cases:
Display selected items as tagsCurrently, the multi-select variant of the Could we display selected items as tags instead and merge this component with FormTokenField? Both serve similar purposes, and showing selections as tags would make it easier for users to reorder or remove items. Use cases:
Support creating new itemsSelect components often allow users to create new items directly. While we currently support this functionality in some editor workflows using separate buttons, would it be feasible to integrate it into the listbox component? For instance, a "create new item" option could appear fixed at the bottom of the listbox, opening a modal when activated by clicking or pressing Use cases:
Hope this helps! cc @brookewp @WordPress/gutenberg-design #66173 |
Hey @jarekmorawski , thank you for sharing your feedback! Here are some thoughts after reading your feedback — looking forward to more feedback from the rest of the folks involved
I'm not sure that's a good approach, as it would incur the risk of blurring the lines too much and mering components and widgets that are semantically different. While, for example, I agree that we could look at "merging" I'm also noticing that every example design in your list is showing a combobox, instead of a listbox. A listbox can be part of a combobox widget, but a combobox widget could also use a
What you're describing here is a Tree View — and in your example, you're using the treeview as part of a As of today, the I will also note that building such component can be tricky, especially in terms of adherence to the WAI-aria specs and the accessibility requirements, and that as of today, most libraries (including ariakit) don't offer a
I agree with you on this one. Exposing an "inline" list as an alternative to the "popover-based" version is something that we intend to do with a few components (
Since you mentioned that "This is a standard feature in many established design systems", it would be great if you could point to UI libraries or products implementing these patterns, which can help us find inspiration on how to implement it on our side.
|
Thank you so much for a detailed response, @ciampo. The semantics are essential and I'm sure we can work out a good solution. I now see that merging all components may not be the way forward and that's perfectly fine as long as the different components we create share DNA, are linked together, and it's clear to consumers when and how they should be used.
It is one of the reasons why we built a custom tree select component at WooCommerce. I believe now is our best chance to improve the one that already exists.
That is unfortunate, but I really hope we can find an approach that strikes a good balance between usability and accessibility. There are several important flows in WooCommerce and other products I work on that would benefit from a robust tree select component. Creating a version of it that meets all the accessibility requirements at the expense of speed and efficiency would be suboptimal for complex flows in Woo where every click matters and either takes you closer or further away from your goal.
Here are examples from Carbon (IBM), Atlassian, Helsinki, and Elvia. All of them also feature other improvements I'm pitching, like nesting and grouping. Atlassian's select component comes with a
Here's an example of a potentially accessible implementation.
Not sure if it helps, but most implementations I reviewed used a group parent item to replicate the functionality of a select/deselect button. Because it's a regular list item with custom functionality, it didn't require any changes to the semantics. Perhaps the 'Create' button could work similarly, or appear as a single button only when there are no results in the list (in such a case, we'd no longer mix components because it wouldn't be part of the same widget). |
Example of a combobox where the listbox is combined with an additional footer containing contextual buttons. |
Thank you for sharing more examples! Here are a few more notes:
|
That's true and I think a combobox can be a good start. It's my primary focus as most data in the admin is text or numbers. I'm curious about the other widget types you mentioned. Do we already use them somewhere?
Salesforce's design system replaces the input's contents with the selected item. It looks like they're stretching the Displaying the X button next to the chevron could work for single-select items (example from an existing DS, another one).
Here's one and another. Not sure they're great references, though. |
Listboxes can be used as controls in their own right, and also power more complex components like Comboboxes and Autocomplete inputs.
Listbox Item
This is the atomic element that makes up the majority of the Listbox component. It can appear as either a checkbox for multi-select listboxes or a radio for single-select listboxes. In the multi-select variant the checkbox is not a checkbox input, merely an element styled to look like one.
Listbox
Listbox is comprised of several elements; notably:
ListboxControl
ListboxControl is the consumable component. It follows the same format as similar components by providing layout and optional elements like a label and help text. Here's a video demonstration of the assembled component:
listbox.mp4
The text was updated successfully, but these errors were encountered: