Edit Lock

Edit Lock is a copy-paste React component that stops approved invoice edited by mistake before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/edit-lock
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsApproved invoice edited by mistake

Was this component page useful?

How do I install Edit Lock?

pnpm dlx shadcn@latest add @bollard/edit-lock

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

How do I use Edit Lock in React?

edit-lock-usage.tsx
import { EditLock } from "@/components/ui/edit-lock"

<EditLock lockedBy="Priya" relockAfter={30_000} onEdit={() => setStatus("Needs re-approval")}>
  <div className="grid grid-cols-2 gap-3 text-sm">
    <label className="col-span-2 space-y-1.5">
      <span className="font-medium">Vendor</span>
      <input className={field} defaultValue="Shree Packaging Pvt Ltd" />
    </label>
    <label className="space-y-1.5">
      <span className="font-medium">Amount (₹)</span>
      <input className={field} inputMode="decimal" defaultValue="1,84,500" />
    </label>
    <label className="space-y-1.5">
      <span className="font-medium">Due</span>
      <input className={field} defaultValue="30 Oct 2026" />
    </label>
  </div>
</EditLock>

What input mistakes does Edit Lock catch?

  • Accidental edits to approved records
  • Unlocking without knowing the consequence, via a confirmation step
  • Approvals voided by an unlock with no real change (only real edits void them)
  • Records left unlocked, by relocking after idleness

What props does Edit Lock accept?

EditLock props
PropTypeDefault
lockedBy* (required)

Who locked it, e.g. "Priya".

string—
reason

Why it is locked, e.g. "approval", "sign-off".

string"approval"
approvalId

Identifies the approval. A new value (a fresh approval) clears the "needs re-approval" state.

string—
locked

Controlled lock state.

boolean—
defaultLocked

Initial lock state when uncontrolled.

booleantrue
onLockedChange

Called when the record locks or unlocks.

(locked: boolean) => void—
onEdit

Called once, on the first change made after unlocking: the moment the approval stops being valid.

() => void—
relockAfter

Relocks after this many ms without any typing, clicking or key presses inside.

number60_000
lockedText

Templates: `{name}`, `{reason}` and `{time}` are filled in.

string"Locked by {name} after {reason}"
unlockLabel

Text for the unlock button.

string"Unlock to edit"
consequenceText

Explains what unlocking means (e.g. re-approval).

string"Any change voids {name}'s {reason}. It will need re-appr…
confirmUnlockLabel

Text for confirming the unlock.

string"Unlock"
cancelLabel

Text for cancelling the unlock.

string"Cancel"
unlockedText

Shown while the record is unlocked.

string"Unlocked · nothing changed yet · relocks in {time}"
editedText

Shown once a change has voided the approval.

string"Edited · needs re-approval · relocks in {time}"
staleText

Shown when the record changed elsewhere.

string"Locked · changed since {name}'s {reason}, needs re-appro…
lockNowLabel

Text for the lock-now button.

string"Lock now"
unlockedAnnouncement

Read to screen readers instead of the ticking visible text, which would be announced every second.

string"Unlocked. Nothing changed yet."
editedAnnouncement

Announced to screen readers when an edit voids the approval.

string"Edited. Needs re-approval."
relockSoonText

Announced once when the idle relock is this close: `{time}` is filled in.

string"Relocks in {time} unless you keep working."
relockWarnWithin

How close the relock must be, in ms, before `relockSoonText` is announced.

number10_000

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

How is Edit Lock accessible?

  • Locks with a native disabled <fieldset>
  • Lock state and edits are announced in an aria-live="polite" region
  • The unlock confirmation focuses its confirm button; Escape cancels and returns focus
  • After unlocking, focus moves to the first field

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

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Enforce the lock on the server: reject edits to approved records unless the approval is voided and logged.

  • A UI lock: the record can still be changed through your API
  • Re-approval is signalled through onEdit; your workflow must act on it

What expensive mistakes does Edit Lock stop?

Approved invoice edited by mistake

Also known as

read only · locked form · approval · invoice · purchase order · fieldset disabled · edit mode · po

Field type

What dependencies does Edit Lock require?

Edit Lock facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameEdit Lock
Registry identifier@bollard/edit-lock
Install commandnpx shadcn@latest add @bollard/edit-lock
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Edit Lock

How does Edit Lock protect destructive mutations?

Edit Lock prevents approved invoice edited by mistake. Enforces deliberate friction against Accidental edits to approved records, Unlocking without knowing the consequence, via a confirmation step, Approvals voided by an unlock with no real change (only real edits void them), Records left unlocked, by relocking after idleness. Limitation: authorize edit-lock mutations on the server.

How do I install edit-lock with shadcn?

Run `npx shadcn@latest add @bollard/edit-lock`. Sources added: registry/default/edit-lock/edit-lock.tsx. Package requirements: lucide-react.

What props customize Edit Lock?

Edit Lock accepts `lockedBy`, `reason`, `approvalId`, `locked`, `defaultLocked`. Configures read only, locked form, approval behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of edit-lock?

A UI lock: the record can still be changed through your API. Re-approval is signalled through onEdit; your workflow must act on it Server requirement: Enforce the lock on the server: reject edits to approved records unless the approval is voided and logged.

How does Edit Lock meet accessibility guidelines?

Locks with a native disabled <fieldset>. Lock state and edits are announced in an aria-live="polite" region. The unlock confirmation focuses its confirm button; Escape cancels and returns focus. After unlocking, focus moves to the first field. Minimizes errors: edited approved record, changed invoice after approval.

Which components pair with Edit Lock?