Architecture decision record · ADR-0012

Editing (milestone M6)

The Grid has one plug-in seam, @editing. The GridEditing interface is in packages/ember/src/grid/types.ts.

Status
Accepted
Deciders
Joe Gaudet
Created
Updated
PRD
PRD
Related
None

Context

Plan section 7 and decisions 19 and 20 set the editing scope. Formwright controls are the cell editors. A Switchyard machine runs the edit states. The engine has the cell selection feature, ported from TanStack Table v9. @ember-lattice/ember must not depend on Formwright or Switchyard, because the Grid works with no editing.

Decision drivers

Not recorded in the original ADR.

Options considered

Not recorded in the original ADR.

Decision

  1. The Grid has one plug-in seam, @editing. The GridEditing interface is in packages/ember/src/grid/types.ts. EditController in @ember-lattice/editing fits it. The Grid owns the keys, the focus, the overlay and the range geometry. The controller owns the values: the edit machine, validation, the save, batch staging and undo.
  2. The editing package uses structural types. It does not import GridEditing and GridEditorSignature, because the index of @ember-lattice/ember does not export them yet. The type check of an app checks that EditController fits @editing.
  3. The column options of editing are a module augmentation. @ember-lattice/editing adds editor, schema, parse and options to LatticeColumnMeta. Thus the Grid package has no Formwright types.
  4. One edit machine for each edit. A save that is in flight does not block the next edit. The controller copies the state of the current machine to a tracked field for the template.
  5. Validation uses Formwright runValidator with the column schema. A paste, a cut and a fill go through the same validation. A value that the schema refuses is not written.
  6. The save is optimistic. The controller keeps a map of pending values. The Grid shows a pending value in place of the row value. When the save ends, the controller removes the entry, and the cell shows the row value again: the new value after a save, the old value after a failure. Batch edit uses the same map, with a staged flag (data-dirty).
  7. Undo is a stack of changes. A change has the value before and the value after. Undo writes the values before; redo writes the values after. A failed save removes its change from the stack.
  8. Ranges use the engine cell selection. The Grid reads getCellSelectionBounds() for aria-selected on cells. A press uses the engine start handler (Shift extends, Ctrl adds). Shift+arrows call extendCellSelection. A move with no Shift makes the new active cell the range. With no range, the active cell counts as the range. Ranges work with client rows only, not with a @rowModel.
  9. The clipboard uses the copy, cut and paste events. The browser sends them on Ctrl+C, Ctrl+X and Ctrl+V. The events need no clipboard permission, and a test can send them with a DataTransfer.
  10. The editor is placed by measurement. The Grid puts the editor at 0, 0 in the overlay, measures where it lands, and moves it by the difference to the edited cell. This works in any containing block and on a scaled page. We did not use Joinery anchorTo or CSS anchor positioning: the cell is in a scroll container, and the overlay is outside it, so the CSS anchor rules do not accept the cell as an anchor in all cases.
  11. The edited row keeps its slot (ADR 0002, amendment 1). The Grid holds the edited row in the same way as the active row. The editor stays on the edited cell when the active cell moves. A press on another cell commits the edit.

Amendment 1 (2026-12-02): row edit, popup edit, scroll and server rows

  • The editor follows its cell on each scroll. Out of the view, it is clipped, not hidden, so the control keeps the focus. The edited row stays held (ADR 0002, amendment 1).
  • Popup edit is a column option, editMode: 'popup'. The Grid puts the same editor under the cell. It does not use the Formwright callout: the callout anchors to the value that the Formwright field shows, and in the Grid the cell shows the value.
  • Full-row edit is new EditController({ rowEdit: true }). The row editor has the Formwright control of each editable column, over its cell. It does not use Formwright Form @inline: that mode shows each value and opens one field on a click, but a row edit opens all fields with one key. The controller validates all fields, and saves the changed values as one undo step.
  • With @rowModel, the Grid owns one range. A paste into rows that are not loaded is refused.
  • The live region of the Grid announces the results of @editing (message). The editing package does not use SwitchyardAnnouncer: the edit machine changes with each edit, and a paste does not use a machine.

Consequences

  • Ctrl+A selects all cells when the table has the cell selection feature. Without it, Ctrl+A selects all rows, as before (contract section 3).
  • A copy of many ranges puts them one after the other. Spreadsheets refuse such a copy.

Remaining work

  • The fill handle does not work with @rowModel. Shift+click does not extend a grid range.
  • A row edit has fields only for the columns in the column range. A field out of the view is not clipped.
  • A row edit does not save when the focus leaves the row editor.

Confirmation

Not recorded in the original ADR.

Interview record

Each question of the interview with its answer and its source. A fact from the code or a document, a question that the author did not ask, and an assumption are rows too.

QuestionAnswerSource
Where does the text of this page come from?From the Markdown file docs/adr/0012-editing.md at commit 4c77ac4. The text of each section is the text of the Markdown file. A section that the Markdown file does not have says so.Document: docs/adr/0012-editing.md

Changelog

DateAuthorChange
2026-12-01Joe GaudetStatus in the Markdown file: accepted, 2026-12-01.
2026-12-02Joe GaudetAmendment 1 (2026-12-02): row edit, popup edit, scroll and server rows
2026-12-03Joe GaudetCommit 7ce4af2: Lattice 1.0 (#1)
2026-12-04Joe Gaudet (agent)Converted from docs/adr/0012-editing.md to this page. The text is the text of the Markdown file.

The adr skill of skillsaw wrote this page. The HTML in this file is the source of truth. The diagrams are the Mermaid sources in it.