Skip to content

Selection and events

A modal is a selection session. Opening it initializes a draft from the committed value. Toggling a row changes the draft; applying commits the draft and closes the modal. Cancelling discards the draft.

Parts to add to order
Choose parts…

Search by part or SKU, select records, then apply. Cancel leaves the previous value unchanged.

Committed value
[]

Pass defaultValue for initial uncontrolled selection. Pass value (including null or an empty array) to control selection externally. With a controlled value, update the parent in onChange; the component does not take ownership of that value.

function PartPicker() {
const [values, setValues] = useState<IdText[]>([]);
return (
<LookupSelect
data={parts}
columns={columns}
mapper={mapper}
mode="multiple"
valueFormat="id-text"
value={values}
onChange={setValues}
/>
);
}

Modal state is independent: defaultOpen sets its initial uncontrolled state, while open and onOpenChange allow the parent to control it.

Event When it fires
onSelectionChange(rows) Draft edits or a trigger clear/remove action; hydrated rows only
onChange(value) Apply, or an immediate trigger clear/remove action
onConfirm(value) Successful Apply, after onChange
onCancel() Cancel action
onOpenChange(open) Requested modal state change
onQueryChange(query) Effective search, sort or pagination changes

A selected row can be deselected even if it later becomes ineligible. Use mapper.getDisabled or selectableRow to prevent adding a record. Select-all toggles eligible records on the current page or filtered local dataset, not every record on the server.