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

ListBox: Backspace/Delete

Open getflourish opened this issue 3 months ago β€’ 5 comments

I want to delete/remove items from a ListBox using keyboard events

I would like to use a ListBox for selection. In addition to onAction(), I need onDelete() or something low-level, such as, onKeyDown() to handle deletion of items.

Currently, neither ListBox nor ListBoxItem allow custom keyboard event handling. I could register a global listener, but: I then need to implement the follow-up selection logic.

I believe this behaviour should be baked into the component. Think about a email inbox in Apple Mail. Or… is there another component that support this interaction?

πŸ€” Expected Behavior?

Press backspace/delete on selected items fires and event / callback.

😯 Current Behavior

Currently, neither ListBox nor ListBoxItem allow custom keyboard event handling. I could register a global listener, but: I then need to implement the follow-up selection logic.

πŸ’ Possible Solution

In addition to onAction(), I need onDelete() or something low-level, such as, onKeyDown() to handle deletion of items.

πŸ”¦ Context

Think about a email inbox in Apple Mail. You can select items, press backspace/delete to remove selected items.

πŸ’» Examples

No response

🧒 Your Company/Team

No response

πŸ•· Tracking Issue

No response

getflourish avatar Aug 18 '25 07:08 getflourish