Skip to content

feat(editable-card): edit a record card in place - #709

Open
itsprade wants to merge 6 commits into
feat/form-layoutfrom
feat/editable-card
Open

itsprade wants to merge 6 commits into
feat/form-layoutfrom
feat/editable-card

Conversation

@itsprade

@itsprade itsprade commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What

A new public component, EditableCard. It edits one card of a record in place: view and edit are the same card with one field list. Every field keeps its exact position when Edit is pressed, and only its value turns into a control. Each card saves on its own.

Refs tailor-inc/platform-planning#2265

<EditableCard<OrderValues> title="Order details" errors={errors} onSave={saveOrder}>
  <EditableCard.Field
    label="Status"
    value={<Badge variant="outline-info">Confirmed</Badge>}
    readOnly={{ reason: "Changes as the order moves through approval." }}
  />
  <EditableCard.Field name="shipTo" label="Ship to" value={order.shipTo}>
    <Select items={warehouses} defaultValue={order.shipTo} />
  </EditableCard.Field>
</EditableCard>

Behaviour

  • One Edit button for the whole card. Save submits only that card, after its fields pass validation.
  • Typed values: EditableCard<Values>. A field with an editor must have a name, enforced by the types.
  • Save results:
    • An async onSave keeps the card in edit mode, with buttons disabled and aria-busy, until it resolves.
    • A rejected or throwing onSave keeps the card in edit mode with the user's changes.
    • Server errors come back through errors and show under their fields.
  • Leaving edit mode: Cancel or Escape leaves edit mode and calls onCancel. An Escape that a Select or Combobox popup already handled doesn't cancel the card.
  • Focus: Edit moves focus to the first control; Cancel, Escape or a successful save return it to Edit.
  • Read-only fields: they keep their view rendering and show a hint icon with the reason in a tooltip. The kinds are system, calculated, locked and permission.
  • Empty values show a dash.
  • Setup: editing can be controlled (editing / onEditingChange), and editDisabled lets a page allow only one card in edit mode at a time.
  • Errors in use: EditableCard.Field throws if it's used outside a card.
  • i18n: strings are in English and Japanese.

Demo

On /showcase/form-templates:

  • E6: edit in place, where fields stay put (with a shift meter).
  • E7: fields you can't edit, one of each kind.
  • E8: several cards on one page, each saved on its own.

Open question: should this be part of DescriptionCard? (needs team alignment)

Important

This needs discussion and agreement with the team before it merges. Treat the API as a proposal. It also overlaps with the TentBox follow-ups (card-level save, merged view and edit) that were assigned to Seiya on 2 Nov.

For designers, EditableCard and DescriptionCard should feel like one card with an optional edit state, and in view mode they should look the same. In code, this PR keeps them separate for now:

  • Editing doesn't follow from display. DescriptionCard knows how to show each field type (a badge, an amount, a reference link). It doesn't know which control edits it:

    • a badge could be a Select with a list of options;
    • an address is really four fields;
    • a reference, such as a supplier, needs a search that loads results.

    Putting all of that into DescriptionCard's fields config would make it much bigger, mostly for cards that are never edited.

  • Most DescriptionCards are only read. Adding form state, validation and save handling would make the simple, common case heavier.

  • It follows the layered plan. Layer 1 is the building blocks (FormLayout and EditableCard). The natural layer 2 lets DescriptionCard opt in to editing by building on EditableCard:

    • an onSave on the card;
    • an edit control on each field that can change.

    Teams already using DescriptionCard would turn on editing without rewriting their cards, and there would still be only one editing engine underneath.

The cost of keeping them separate is that the two describe fields differently: JSX children here, a fields config in DescriptionCard. So a page could end up describing the same fields twice.

For the team to agree on:

  1. Should they stay separate now, with DescriptionCard opting in later? Or should DescriptionCard get an edit mode from the start?
  2. Should they look the same in view mode? EditableCard's spacing and label styles follow FormLayout fields, and they haven't been compared side by side with DescriptionCard yet.
  3. Who owns this, given Seiya already has the TentBox follow-ups?

Testing

  • 30 tests cover:
    • validation blocking Save
    • focus after each switch
    • Cancel restoring values
    • Escape, including from a popup or a control that already handled it
    • async, rejected and throwing saves
    • the errors prop
    • read-only kinds, and Japanese strings
  • A type test covers the generic values and the required name.
  • Checked in the browser.
  • All checks pass: tests (3,155), types, lint, format, docs and check-dts.

Stack

A separate component, released after the forms work. It builds on FormLayout's grid, so it's stacked on #708 and retargets to main when that merges. #708 doesn't need it to merge. It doesn't depend on Stepper (#707).

🤖 Generated with Claude Code

Add EditableCard and EditableCard.Field. View and edit are one card with
one field list: each field renders the same cell in both modes (a fixed
label row and a value slot the height of a control), so pressing Edit
moves nothing and only swaps values for controls.

Fields that can't be edited keep their view rendering and, in edit mode,
show an icon whose tooltip gives the reason, by kind: system, calculated,
locked or permission. Save submits only this card; an async onSave keeps
the card in edit mode until it resolves and stays there if it rejects.
Labels are translated into English and Japanese.

The form templates page gets three in-place examples: a purchase order
header with every read-only kind, a table of the kinds, and two cards
where only one can be edited at a time.

Refs tailor-inc/platform-planning#2265

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

# Conflicts:
#	docs-manifest.json
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (923933d) #709 (e039ced) +/-
Coverage 62.9% 63.0% +0.1%
Test Execution Time 4m3s 4m0s -3s
Details
  |                     | main (923933d) | #709 (e039ced) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          62.9% |          63.0% | +0.1% |
  |   Files             |            294 |            299 |    +5 |
  |   Lines             |          13483 |          13657 |  +174 |
+ |   Covered           |           8485 |           8617 |  +132 |
+ | Test Execution Time |           4m3s |           4m0s |   -3s |

Code coverage of files in pull request scope (14.2% → 16.2%, patch 100.0%)

Files Coverage +/- Patch Coverage Status
dist/auth-context-DKJ0CX7P.js 0.0% -46.2% - affected
packages/core/dist/app-shell.js 8.8% +0.2% - affected
packages/core/dist/auth-context-h5dden34.js 46.2% +46.2% - affected
packages/core/src/components/dialog/dialog.tsx 97.4% +0.2% - affected
packages/core/src/components/editable-card/editable-card.tsx 100.0% +100.0% 100.0% added
packages/core/src/components/editable-card/i18n.ts 100.0% +100.0% 100.0% added
packages/core/src/components/editable-card/index.ts 0.0% 0.0% - added
packages/core/src/components/form-layout/form-layout.tsx 100.0% +100.0% - affected
packages/core/src/index.ts 0.0% 0.0% - modified

Reported by octocov

@itsprade
itsprade marked this pull request as draft November 10, 2026 15:23
# Conflicts:
#	docs-manifest.json
#	docs-src/skill/SKILL.template.md
# Conflicts:
#	docs-manifest.json
#	docs-src/components/form-layout.docs.outline.md
#	docs-src/skill/SKILL.template.md
#	docs/components/form-layout.md
#	examples/vite-app/src/pages/showcase/form-templates/overview.tsx
@itsprade
itsprade marked this pull request as ready for review November 17, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant