react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

ListBox with selectionMode="multiple" not working inside Combobox component

Open tordsta opened this issue 1 year ago โ€ข 2 comments

Provide a general summary of the issue here

I think the core of the issue is that the behavior of ListBox should be consistent when placed inside different wrappers such as ComboBox. This is also relevant for ListBox inside the Select component. I know the docs specify that multiple selections is not possible for the Select component, but it is still weird and confusing that one can have a ListBox with the selectionMode="multiple" inside a Select component. Furthermore I can not find the same single select restriction in the documentation for ComboBox or ListBox, leading me to believe this is a bug.

๐Ÿค” Expected Behavior?

ListBox with selectionMode="multiple" does not work inside a Combobox.

๐Ÿ˜ฏ Current Behavior

ListBox with selectionMode="multiple" does not work inside a ComboBox.

๐Ÿ’ Possible Solution

Some alternatives:

  1. Make the ListBox with selectionMode="multiple" work inside ComboBox. I guess the value would need to be an array of keys instead of a single key to make it work.
  2. If this is intended behavior, update the documentation of ComboBox and ListBox. Specify that ComboBox is single select. On the ListBox page add a "Gotcha"/warning about selectionMode="multiple" not working when placed inside Select and ComboBox.

๐Ÿ”ฆ Context

Filter with multiple options selected. Selection of multiple floors a tenant is on. Etc. just dropdown multi select in general.

๐Ÿ–ฅ๏ธ Steps to Reproduce

https://codesandbox.io/p/sandbox/awesome-dawn-n8p4pn

Version

1.2.1

What browsers are you seeing the problem on?

Other

If other, please specify.

Arc

What operating system are you using?

macOS Sonoma 14.1

๐Ÿงข Your Company/Team

Propely

๐Ÿ•ท Tracking Issue

No response

tordsta avatar Jun 19 '24 10:06 tordsta

Also another possible solution is to separate out the ListBox into two different concepts. One that is ListBox with ListBoxItems, with a selectionMode="multiple". And another one that is OptionBox (or whatever) and OptionBoxItem witch is only single select. And then using OptionBox in ComboBox and Select, while ListBox is standalone.

tordsta avatar Jun 19 '24 10:06 tordsta

Related https://github.com/adobe/react-spectrum/issues/2140

snowystinger avatar Jun 19 '24 11:06 snowystinger