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

Disable entire ListBox without needing to set disabledKeys

Open jagregory opened this issue 1 year ago โ€ข 1 comments

Provide a general summary of the feature here

Hey folks,

I have a ListBox which is displayed inline (aka not popped out by a trigger) inside a component which can be disabled. I'd like to be able to disable a ListBox component entirely without needing to know ahead of time what the items are within the ListBox. Adding aria-disabled would make sense I think too.

๐Ÿค” Expected Behavior?

<ListBox items={...} isDisabled> should disable interaction with all items in the ListBox, and possibly set aria-disabled on the ListBox outermost element.

๐Ÿ˜ฏ Current Behavior

Currently it's not possible to disable a ListBox, you have to provide a disabledKeys prop with the id of all the items. This is problematic if you don't know what the items are ahead of time, or just error prone if the list is manually created.

๐Ÿ’ Possible Solution

No response

๐Ÿ”ฆ Context

I have an area of my page which is enabled or disabled based on state, the ListBox is inside an area which should be disabled.

๐Ÿ’ป Examples

No response

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

jagregory avatar Feb 08 '24 05:02 jagregory

Perhaps we could expand the disabledKeys type to include all as an option like selectedKeys does. Including a top level isDisabled makes sense to me as well, will have to keep an eye out for updates to the 1.2 aria spec in case they decide to deprecate it on the listbox role (looks like they won't at the moment).

LFDanLu avatar Feb 12 '24 19:02 LFDanLu