Namesake Select

Flags options that share a name and asks for one identifier before a shared name is picked, so the right name doesn't go to the wrong person.

StopsRight name picked for wrong person

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/namesake-select.json

The files land in your project. They're yours to edit.

Usage

namesake-select-usage.tsx
import { NamesakeSelect, type NamesakeOption } from "@/components/ui/namesake-select"

<NamesakeSelect label="Attach lab report to patient" options={patients} value={patient} onValueChange={setPatient} />

What it catches

  • Two or more people with the same name, however it is typed
  • The details that tell namesakes apart, shown inline
  • Picking a shared name: re-entry of one identifier is required (default verify="reenter")
  • Identifier that matches a different namesake: one-tap switch
  • Identical records that can't be told apart

Props

NamesakeSelect props
PropTypeDefault
options* (required)

People to choose from, each with a name and identifying details.

NamesakeOption[]—
value

Selected id (controlled). `null` means none.

string | null—
defaultValue

Initial selected id when uncontrolled.

string | nullnull
onValueChange

Fires with the chosen id, or `null` when the text is edited away. With `verify="reenter"`, a name someone else shares only becomes the value once confirmed.

(id: string | null) => void—
verify

`reenter` (default) asks for one identifier when a picked name is shared; `readback` only shows the identifiers. Re-entry cut wrong-patient orders about twice as much as a confirm alert did (Adelman et al., JAMIA 2013).

"reenter" | "readback""reenter"
label* (required)

Visible label of the field.

string—
identifiers

How many identifying details to read back once chosen. Two, as patient-safety practice asks.

number2
messages

Override any visible string.

Partial<typeof NAMESAKE_SELECT_MESSAGES>—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Combobox with a visible label, aria-expanded and arrow-key/Enter navigation
  • Focus moves into the verification card and back to the input
  • Animations are skipped under reduced motion

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Re-check the selected record ID on the server before acting on it (orders, payments, records).

  • Only as good as the identifiers you pass (date of birth, city, phone)
  • Name matching ignores case, accents, punctuation and word order, but not nicknames or transliteration variants
  • Re-entry adds a step for every shared name, by design

What it stops

Right name picked for wrong person

Also known as

namesake · same name · patient select · customer picker · contact picker · people search · duplicate records · crm

Field type

Dependencies

Pairs well with