Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .changeset/35827-data-table-staged-edit-retired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
'@object-ui/types': minor
'@object-ui/components': minor
'@object-ui/plugin-grid': minor
'@object-ui/app-shell': minor
'@objectstack/spec': minor
---

feat(ui): the grid's staged edit model retires with its interface, so every editable grid selects a cell first and saves each cell on its own

Clause-②: no (narrowing)
Metadata-protocol: narrowed

<!-- adr-0087: registered data-table-staged-edit-retired -->

**BREAKING** accept-set narrowing on the grid's host interface: `ObjectGrid`'s `cellSelection` prop and `onBatchSave` prop (`@object-ui/plugin-grid`), and `DataTableSchema.onBatchSave` and `DataTableSchema.singleClickEdit` (`@object-ui/types`). The staged model behind them goes in the same release (`@object-ui/components`).

- **Now.** There is one way to edit a grid. A grid that renders editable selects a cell on a click; double-click, Enter, F2 or typing opens its editor; Esc cancels; and each committed cell is saved at once as one update for its record, through the host's `onRowSave` or, when there is none, the grid's own `dataSource.update`. The pending-changes bar, its "Save All" and "Cancel All" buttons, the per-row save/cancel column and the amber "modified" tints are gone everywhere. A grid that renders read-only keeps its click-to-open row, and a host may still pass `cellSelection={true}` to ask for the select-first model on a read-only grid.
- **A bare `data-table`.** An editable `data-table` edits only inside a select-first host (`GridCellSelection`) that also passes `onRowSave`. Without both it renders read-only and logs one console warning naming what is missing, instead of staging edits it has nowhere to save. Render an `object-grid`, which mounts both and writes through its data source.
- **Unchanged.** Who may edit what: `editable`, the object's inline-edit affordance, the reader's `update` grant, per-field write grants, the record-grained verdict and approval locks all narrow editing exactly as before.

| FROM | TO |
|:--|:--|
| `<ObjectGrid cellSelection={false}>` to keep click-to-edit and the "Save All" bar | drop the prop; an editable grid is select-first, and a read-only one opens a record on a click |
| `<ObjectGrid onBatchSave={…}>` | pass `onRowSave(rowIndex, changes, row)` to own the write record by record, or pass nothing and let the grid save through its own `dataSource.update` |
| `data-table` schema `onBatchSave: (changes) => …` | `onRowSave` inside a `GridCellSelection` host, or render `object-grid` |
| `data-table` schema `singleClickEdit` | delete the key; a click selects the cell and double-click, Enter, F2 or typing opens its editor |
| an editable `data-table` with no `GridCellSelection` host or no `onRowSave` | mount `GridCellSelection` and pass `onRowSave`, or render `object-grid`; until then it renders read-only and warns |

The one-line fix: delete `cellSelection={false}`, `onBatchSave` and `singleClickEdit` wherever a host writes them, and pass `onRowSave` where a batch handler did the write. Passing `cellSelection={false}`, `onBatchSave` or `singleClickEdit` after upgrade fails `tsc` (`cellSelection` accepts only `true`, `onBatchSave` is `never`, `singleClickEdit` is no longer declared), and the `data-table` mirror refuses `onBatchSave` by name as retired. None of these is authorable metadata, so `os migrate meta` has nothing to rewrite; its D3 entry `data-table-staged-edit-retired` names what the upgrade still owes: host code that relied on one transaction per Save All, and help text and tests that describe the old gestures.

The retirement kit:

- **`@object-ui/types`**: `DataTableSchema.onBatchSave` is `?: never` on the TS face and a `retired` handler-key refusal on the zod mirror; `DataTableSchema.singleClickEdit` is removed; the `editable`, `onRowSave` and `onCellChange` docs say a commit is the save. The parity ledgers drop both keys.
- **`@object-ui/components`**: `data-table` loses the staged arm (pending-changes bar, Save All / Cancel All, row save/cancel buttons, edit-only column, click-to-edit, the amber tints) and its fallback copy rows (`table.saveAll`, `table.cancelAll`, `table.modified`, `table.saveRow`, `table.cancelChanges`). An editable table without a select-first host and `onRowSave` renders read-only with a `[ObjectUI] DataTable editable:` console warning.
- **`@object-ui/plugin-grid`**: `cellSelection` accepts only `true`; `onBatchSave` and the default batch save are removed, and the default cell save keeps its rule check, `If-Match` guard, conflict dialog, Undo and toast. `keyboardNavigation`'s describe drops its staged sentence.
- **`@object-ui/app-shell`**: the metadata resource list stops passing `cellSelection={false}`; it is read-only, so it keeps click-to-open.
84 changes: 32 additions & 52 deletions content/docs/frontend/plugins/plugin-grid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,16 @@ verdict.

### Row callbacks are component props

`onRowClick`, `onRowSelect`, `onCellChange`, `onRowSave`, `onBatchSave`,
`onRowClick`, `onRowSelect`, `onCellChange`, `onRowSave`,
`onEdit`, `onDelete`, `onBulkDelete` and `onAddRecord` are React props on
`ObjectGridComponentProps`. They are functions, so no metadata document can hold
them, and writing one of them into a schema does nothing at all: the grid builds
the inner table's handlers itself and never reads any of these nine off the
the inner table's handlers itself and never reads any of these eight off the
schema.

The one callback the grid does read off the schema is `onNavigate`, declared on
`ObjectGridSchema` for programmatic callers only. It is a function value too, so
it is no more authorable than the nine — it is deliberately absent from the
it is no more authorable than the eight — it is deliberately absent from the
manifest and the designer panel, and prefer passing it as a prop
(objectui#5234, maintainer ruling of 2026-08-19).

Expand Down Expand Up @@ -411,16 +411,12 @@ retired (objectstack#36270): `@objectstack/spec` refuses it, and
definition**, not by a column key — a field marked `readonly`, and
computed/binary field types (formula, autonumber, file, …), never open an
editor. There is no `editable` key on `ListColumn`.
- **Rich text edits in a panel** (objectstack#36023): on a select-first grid
(`cellSelection`), a `markdown`, `html` or `richtext` cell opens the record
- **Rich text edits in a panel** (objectstack#36023): a `markdown`, `html` or `richtext` cell opens the record
form's text box over the stored source in a panel under the cell, at least as
wide as the column, while the cell keeps showing its value. Enter there is a
new line, Ctrl/Cmd+Enter saves, Esc discards and a click outside saves. A grid
without `cellSelection` opens the text box over the cell on one click: Enter
is a new line, Ctrl/Cmd+Enter does nothing, Esc discards and a click outside
keeps the text as a pending change for the grid's save buttons.
- **Visual feedback**: editable cells show a hover state, and the input is
focused and selected when editing begins
new line, Ctrl/Cmd+Enter saves, Esc discards and a click outside saves.
- **Visual feedback**: the selected cell is ringed, and the editor opens with
the caret after the value
- **The editor floats over its cell** (objectstack#35688): it opens on a layer
anchored to the cell's top-left corner, at least as wide as the column and
wider where its field type needs it (an address form, a record picker), so
Expand Down Expand Up @@ -449,9 +445,10 @@ page, the grid an `object-view` draws, and an authored `object-grid`. There is
no inline-edit mode and no toggle. On the list page the grid is editable
wherever the reader may edit the object and the view does not declare
`userActions.editInline: false`; elsewhere it is editable where `editable` is
set and the reader may edit the object. A React host can pass the
`cellSelection` component prop (not a schema key) as `false` to keep the staged
model described under [Batch Editing](#batch-editing--multi-row-save).
set and the reader may edit the object. There is no other editing model: the
staged one (click-to-edit, a pending-changes bar and "Save All") is retired, and
so is the React host's `cellSelection={false}` that kept it (objectstack#35827) —
see [Owning persistence](#owning-persistence-onrowsave).

- **A click selects** a cell (a ring around it); it neither edits nor opens the
record. Only the name link keeps its own click (it opens the record). Every
Expand Down Expand Up @@ -612,22 +609,16 @@ WAI-ARIA grid pattern (objectui#11068):
`editable` *and* the viewer's permission to update the object, the same value
inline editing obeys — because that grid selects a cell first and moves the
selection with these keys; `false` does not turn it off there
(objectstack#36270), except where a React host keeps the staged model with
`cellSelection={false}` (see Batch Editing below). A read-only grid keeps every
cell its own Tab stop unless you write `true`.
(objectstack#36270). A read-only grid keeps every cell its own Tab stop unless
you write `true`.
- While it is on, the table is exposed to assistive technology as a `grid`. A
grouped grid navigates within each group's table; the mobile card layout has
no cells and is unaffected.

### Batch Editing & Multi-Row Save
### Owning persistence: `onRowSave`

Edit multiple cells across multiple rows and save them individually or all at
once. This is the staged model, which no metadata selects: since
objectstack#36270 every grid that renders editable saves each cell as it is
committed (above). A React host that draws `ObjectGrid` itself opts back into
it by passing `cellSelection={false}`; then a click opens a cell's editor, and
the save/cancel affordances appear on their own once a row has pending
changes:
An editable grid needs no prop to edit: it selects a cell first and saves each
committed cell as it goes.

```tsx
import { ObjectGrid, type ObjectGridComponentProps } from '@object-ui/plugin-grid';
Expand All @@ -636,7 +627,6 @@ declare const dataSource: NonNullable<ObjectGridComponentProps['dataSource']>;

export const ProductsGrid = () => (
<ObjectGrid
cellSelection={false}
dataSource={dataSource}
schema={{
type: 'object-grid',
Expand All @@ -653,49 +643,39 @@ export const ProductsGrid = () => (
);
```

Left alone, saving goes through the host's data source. A React host that needs
to own persistence supplies `onRowSave` / `onBatchSave` as **component props** —
and because they are props, they take the adapter from the host's own scope
rather than from anything in the schema:
Each committed cell is written through the host's data source. A React host that
needs to own persistence supplies `onRowSave` as a **component prop** — and
because it is a prop, it takes the adapter from the host's own scope rather than
from anything in the schema. It is called once per commit, with every edit that
record still holds:

```tsx
import type { ObjectGridComponentProps } from '@object-ui/plugin-grid';

type Persistence = Pick<ObjectGridComponentProps, 'onRowSave' | 'onBatchSave'>;
type Persistence = Pick<ObjectGridComponentProps, 'onRowSave'>;

const persistence = (
dataSource: NonNullable<ObjectGridComponentProps['dataSource']>,
): Persistence => ({
onRowSave: async (rowIndex, changes, row) => {
await dataSource.update('products', row.id, changes);
},
onBatchSave: async (allChanges) => {
await Promise.all(
allChanges.map(({ row, changes }) => dataSource.update('products', row.id, changes)),
);
},
});
```

**Features:**
- **Pending changes tracking**: edit multiple cells across rows before saving; a
cell edited back to the value it loaded with is not a pending change, and its
row is no longer counted as modified
- **Visual indicators**: modified rows highlighted in amber, modified cells in bold
- **Row-level save/cancel**: individual row save and cancel buttons
- **Batch operations**: Save All and Cancel All buttons for bulk actions
- **Flexible callbacks** — all three are `ObjectGridComponentProps`, never schema
keys: `onRowSave` for a single row, `onBatchSave` for many, `onCellChange` for
each committed cell edit, including one that leaves the value as loaded (only a
real change is staged). `onBatchSave` is `@deprecated`: only this staged model calls it;
on a select-first grid each cell saves through `onRowSave` (or the grid's own
write) and `onBatchSave` is never called
- **A concurrent write is refused, not overwritten**: the default saves send each
`cellSelection` takes only `true`: it asks for the select-first model on a grid
that renders read-only. **Upgrading from the staged model** (objectstack#35827):
drop `cellSelection={false}`; move a batch `onBatchSave(allChanges)` handler to a
per-record `onRowSave(rowIndex, changes, row)`, or drop it and let the grid write
through its data source.

- **A refused save keeps the edit**: the cell keeps what was typed and says the
server's reason; the record's next commit sends it again with the new cell.
- **A concurrent write is refused, not overwritten**: the default save sends the
row's `updated_at` as `If-Match`, and an editable grid asks for that column even
when no column shows it. A row someone else saved after it was read answers
`409`, which opens the record page's conflict dialog (Reload latest, Overwrite
anyway, Cancel). "Save All" reports each row on its own: a refused row stays
pending and flagged, and the rows that saved are cleared.
anyway, Cancel).

## TypeScript Support

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

import type { SemanticMigration } from '../../types.js';

// The data-table staged-edit retirement (ruling record 7178367040, route A: the
// staged model and its interface retire together), its D3 entry. No D2
// conversion: nothing it retires is authorable metadata (`onBatchSave` is a
// host function the parse already refused by name, and `cellSelection` is a
// React prop of `<ObjectGrid>`), so there is no source to rewrite. What the
// consumer still owes is the host code and the tests that drove the old model.
export const entry: SemanticMigration = {
id: 'data-table-staged-edit-retired',
surface: 'object-grid / data-table host interface — the staged edit model: `<ObjectGrid cellSelection={false}>`, '
+ 'the `onBatchSave` handler on `<ObjectGrid>` and on the `data-table` schema, `data-table`\'s '
+ '`singleClickEdit`, and an editable `data-table` mounted without a cell-selection host or an '
+ '`onRowSave` handler',
replacement: 'Select-first editing with one save per committed cell. Pass `onRowSave` to `<ObjectGrid>` to own '
+ 'persistence record by record, or pass nothing and let the grid write through its own '
+ '`dataSource.update`. A host may still pass `cellSelection={true}`; without the prop an editable grid '
+ 'is select-first and a read-only grid opens a record on a click. A bare `data-table` edits only '
+ 'inside a cell-selection host with an `onRowSave` handler, or is rendered as `object-grid` instead.',
reason: 'The staged model kept edited cells as pending changes behind a "Save All" bar and handed them to '
+ '`onBatchSave` together. It is gone, not deprecated: `cellSelection` accepts only `true`, `onBatchSave` '
+ 'is a `never` key on both type faces and refused by name in the parse, and `singleClickEdit` is no '
+ 'longer declared. A host that passed `cellSelection={false}` to get click-to-edit and a save bar now '
+ 'gets select-first editing that saves each cell as it is committed, so a batch handler it relied on '
+ 'for one transaction per save is never called. An editable `data-table` without a cell-selection host '
+ 'and an `onRowSave` handler now renders read-only and logs a console warning instead of staging edits '
+ 'it had nowhere to save. Only the host\'s author can tell whether per-record saves are acceptable where '
+ 'a batch was, and which help text and tests describe the old gestures.',
acceptanceCriteria: 'No host passes `cellSelection={false}` or an `onBatchSave` handler, and no `data-table` '
+ 'schema carries `singleClickEdit` or `onBatchSave`; the type check refuses all of them. Every editable '
+ 'grid either passes `onRowSave` or relies on its data source to save each committed cell, and its help '
+ 'text and tests describe a click that selects a cell, a double-click, Enter, F2 or typing that opens its '
+ 'editor, and no "Save All". No editable `data-table` logs the read-only warning at mount.',
};
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,6 @@ function DefaultMetadataList({ type, appName }: { type: string; appName?: string
return info?.invalid ? 'red' : info?.warnOnly ? 'amber' : null;
}}
rowOpensRecord={false}
cellSelection={false}
onRowClick={(rec, event) => {
const info = rowInfoOf(rec);
if (!info || (event && (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey))) return;
Expand Down
Loading
Loading