Editable detail row

DarkInspect

A label and its value that edits in place, for the staff sheets in admin: click the value, change it inside an Input group, then Enter or the check saves and Escape or the cross discards. It is ReUI's sheet-9 row, verbatim apart from our small-control corner. Every inline edit in an admin sheet is this row, whatever the field: text, a select, a date, a switch. It is not for the storefront, where a member edits a form.

The example shows, from the top: two editable rows (the phone with a hint behind its info icon), a row saving, and a read-only row.

Usage

<EditableDetailRow
  label="Phone"
  hint="Used only for delivery updates and the courier."
  display={<span className="truncate text-sm">{phone}</span>}
  editing={editing}
  saving={saving}
  onEdit={() => setEditing(true)}
  onCancel={() => setEditing(false)}
  onSave={save}
  renderEdit={(active) => (
    <InputGroupInput disabled={!active} value={draft} onChange={…} />
  )}
/>
  • display is the value at rest; renderEdit is the control inside the input group, and active is false while the row saves.
  • Without renderEdit (or without the three handlers) the row is read-only: the value with no pencil.
  • saving swaps the check for a spinner and locks the row; the caller owns the action, the optimistic value and the rollback.
  • align="start" tops the label for a value that runs over several lines (an About text).
  • hint puts an info icon after the label with the text in a tooltip, so the row needs a TooltipProvider above it.

On this page