DataViews: Single-selection pickers should show a radio and support non-selectable items
What problem does this address?
DataViewsPicker with the pickerTable layout is the right tool for "pick one item from a list": the whole row is clickable and selection is handled for you. Two things make it hard to use for a single choice:
- It always shows a checkbox. With single selection (all actions
supportsBulk: false), each row still has a checkbox. A radio is the control people expect for "pick one", and it tells them only one can be picked. - Every item can be selected. The selection hook (
useSelectionProps, #80677) takes anisItemSelectablepredicate, but the picker layouts always pass() => true. There's no way for a consumer to say "this one can't be picked", for example the plan the user already owns, or an option that doesn't apply to them.
Here's a single-selection picker today:
For now we use the regular table layout with a radio field in the first column, which loses the row click.
What is your proposed solution?
- Radio for single selection. When the picker's selection mode is single (
'single'or'single-required'), render a radio instead of a checkbox inpickerTableandpickerGrid. This could be derived from the existing mode so most consumers get it for free, with a layout-level option if an explicit control is wanted. - Expose
isItemSelectable. Let consumers pass a predicate toDataViewsPicker, and have the picker layouts forward it instead of() => true. A non-selectable row would render its radio or checkbox disabled, skip row-click selection, and be left out of select-all.
Here's a mockup of both on the same list, with the first item marked as not selectable:
Both would also help the list and pickerActivity layouts, which hard-code () => true today.
Happy to help test.
I can reproduce this in the pickerTable layout. With isMultiselectable set to false, selecting another row replaces the previous selection, but the controls still show checkboxes. Radios would communicate the single-selection behavior more clearly.
The picker layouts also hard-code isItemSelectable: () => true, which confirms the limitation described above.
One related observation: after selecting four items with multiselection enabled, switching isMultiselectable to false leaves all four selected, and the counter still shows “4 selected”. Is preserving the existing selection intentional, or should switching to single-selection mode clear it or retain only one item?