Repository navigation
Commit fac1e7d
feat(list): a list cell saves the moment it is committed, and Space types into the selected cell (#35864)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu35nceJccLpnzyY9BMfwJv9)_
repo:objectstack#1 · os-sales · session_01L6bhgUYnzYCcbcpABdW7ps
Part of #35685 (slice S1 of three; S2 undo and S3 state-machine confirm
+ drawer sync follow in their own pull requests, so the card stays open)
Clause-②: yes (widening) — new members on the `@object-ui/react` package
entry: `createOwnWrites`, `OwnWritesContext`, `useOwnWrites` and the
`OwnWrites` type, and an optional third parameter on
`useDataInvalidation`; three new `table.*` keys in every
`@object-ui/i18n` locale (`cellSaving`, `cellSaved`,
`openRecordToFinish`); nothing removed or renamed
Metadata-protocol: none
Skills-docs: `content/docs/frontend/plugins/plugin-grid.mdx` — the "On
an object's list page" section now says Space types into the cell and
each commit saves at once (with the refusal and 409 behaviour), and
"Batch Editing & Multi-Row Save" says it is the model of a grid without
select-first. No skill under `skills/` teaches the save bar, the row
Save/Cancel buttons or the Space key
(`skills/objectstack-ui/rules/list-views.md` only says inline editing is
on by default, with `userActions: { editInline: false }` as the
opt-out), so nothing there moves.
## 维护者速读
- 所有用列表组件(ListView)画出的表格:改完一个格子(回车、Tab、点别处)就立刻保存这一格,不再有"全部保存 /
全部取消"栏、行尾的保存/取消按钮和整行黄色底;格子上有一个小转圈表示正在保存,保存后出现一个小对勾。
-
保存只更新这一行,用服务器返回的值(服务器规则改写过的值会如实显示),不再整表重新读取;按某列排序时,改过的行留在原位,等下次刷新、换排序、筛选或翻页才归位(Sales
裁决 7039615827 第 1 条)。
- 保存被拒时,格子保留刚输入的值并直接显示服务器给的原因,按 Esc
恢复成原来的值;同一行接着改别的格子,会和被拒的那格一起作为一次更新发出;原因涉及列表里没有的字段时,提示里有"打开记录完成修改"。409
冲突对话框不变。
- 空格改为和打字一样进入编辑(布尔格仍是切换),按维护者的原话去掉了 #35747
加的"空格打开记录";所以打开记录只剩点名称和触屏轻点,主从页面(如 Task
Desk)打开右侧面板也一样。没有挂选中格模型的旧表格(相关列表、仪表盘表格等)保持原来的保存栏,等 #35827 的后续迁移。
## What changes
**Per-cell autosave in the select-first grid** (`@object-ui/components`,
`data-table`). Only a table under `GridCellSelectionProvider` changes:
that is every grid `ListView` draws, because `ListView` passes
`cellSelection: true` to `ObjectGrid` (the scope Sales ruled in
7035276698). Every other table keeps the staged save bar exactly as
before.
- A committed cell (Enter, Tab, a click elsewhere, a toggle, a paste) is
saved at once through the grid's existing `onRowSave`, as ONE update
carrying the row's pending fields. An unchanged commit sends nothing.
- The save bar, the "N rows modified" banner, the row Save/Cancel
buttons (and the edit-only trailing column that held them) and the amber
row/cell tint are not drawn in this model.
- The cell shows a small spinner while its save runs and a check mark
for 1.5 s once it landed (`data-slot="cell-save-state"`,
`role="status"`, new `table.cellSaving` / `table.cellSaved` strings in
all 11 locales).
- A refusal keeps the typed value on the cell and opens a notice
anchored to it with the server's reason (field reasons per drawn column;
a reason naming no drawn field goes on the sent cell). When the refusal
names a field that is not an editable column of this list, the notice
offers **Open the record to finish this change**
(`table.openRecordToFinish`), which calls the host's row click.
- **Esc** on that cell, in its editor or on the selected cell, puts the
stored value back and drops the notice. A later edit on the same row is
sent together with the refused one, as one update.
- A commit made while the row's save is still running waits and is sent
right after it, so a row never has two writes in flight. Esc while that
save runs (in the editor or on the selected cell) takes back only the
edit being made, never the value on the wire.
- A select-first table with no `onRowSave` (wired with `onBatchSave`
alone) does not autosave: it keeps the staged save bar, the row buttons
and the tint exactly as #35684 drew them, so an edit is never held where
nothing can send it. `ObjectGrid`, the only host today, always passes a
row save.
- Client sort and search keep using the pre-save row until the rows load
again (`sortBasis`), so a row the user just edited does not jump under
the cursor.
**Only that row is redrawn** (`@object-ui/plugin-grid`,
`@object-ui/plugin-list`, `@object-ui/react`).
- `ObjectGrid.defaultRowSave`, when the host mounted `cellSelection`, no
longer bumps its refresh key. It overlays the saved row from the write's
answer (`mergeSavedRow` in the new `objectGridRowPatch.ts`): `{ ...row,
...changes }` and then every key of the answer the row already carries,
so a server hook's rewrite shows as stored; a lookup the answer names by
the same id keeps the expanded record the row read. The overlay applies
only while the grid still holds the row object it was saved from, so the
next load replaces it.
- The data source still announces the write (`onMutation`, and the
console's bridge onto the data-invalidation bus), which made `ListView`
read every row again. `@object-ui/react` adds a small registry for
"writes this reader draws itself": `createOwnWrites()`,
`OwnWritesContext` / `useOwnWrites()`, and an optional `ownWrites`
argument on `useDataInvalidation`. `ListView` provides one; `ObjectGrid`
holds the record there for the length of its write; `ListView`'s
`onMutation` subscription and its bus reader (and the grid's own row
load, for a grid that fetches for itself) let a change naming a held
record go by. Every other reader (the record's detail pane, related
lists, counts, the footer's whole-set summary) is not given the registry
and refreshes as before; an object-wide change or `'*'` is never
absorbed. On a 409 the hold stays through the dialog and the "Overwrite
anyway" write, so that write re-reads no row either; only "Reload
latest" lets go first (`resolveRowConflict`'s new `beforeReload`), so
its reload reaches the list.
- The next save on a row sends the `If-Match` version the previous save
answered.
- `writeRowGuarded` now returns the write's answer; `resolveRowConflict`
returns `{ outcome: 'saved', result } | { outcome: 'reloaded' }` (both
internal to `ObjectGrid`).
**Space types into the selected cell.** The maintainer, on #35683
(comment 7037290299, transcribing their own check):
「选中任意格后按空格,他是进入编辑了,没有你说的规则」 ("after selecting any cell and pressing
Space, it goes into editing; there is no such rule as you described").
So the "Space on a selected cell opens the record" key that #35747 added
is removed: Space is typed like any other key and opens the editor with
a space; a two-state cell still flips on Space. The record opens from
the title link or a touch tap.
## Why
#35685 asks for the list to save as the user edits, like a spreadsheet,
without a mode, a bar or a refetch that moves rows; Sales ruled the
sorted-row timing (「等下次取数才归位」, ruling record 7039615827 item 1). Item 2
of that record (the state-machine confirm wording) belongs to S3.
## Acceptance notes (behaviour changes a reviewer should know)
- **Scope:** autosave is on only in tables that mount
`GridCellSelectionProvider`, i.e. `ListView` grids. Related lists,
dashboard tables and other `ObjectGrid` hosts without `cellSelection`
keep the staged save bar and `onBatchSave`; #35827 stays open for their
migration (comment 7039688829).
- **Master-detail pages** (for example the showcase task desk): a
selected cell no longer opens the side pane on Space. The pane opens
from the title link or a touch tap.
- **Sorted lists:** a saved row stays where it is until the next load
(refresh, sort, filter, page change). Counts on group headers, which are
read with the rows, follow on that load too; the footer's whole-set
summary refreshes on the write.
- The save toast ("1 row saved") is unchanged and still raised once per
landed save; S2 adds Undo to it.
## Review round 1 (heads `c552f8a3` and `f836ec36`, after `9970dffd`)
From the declaration L2 (PASS, comment 7041830485) and L1 (comment
7041864536):
- should-fix: a 409 "Overwrite anyway" re-read the whole list → the hold
now covers the overwrite write; test added.
- should-fix: a select-first table without `onRowSave` would hold edits
nothing could send → it falls back to the staged save bar (chosen over
failing loud: the bar is the existing, tested model for such a table);
test added.
- must-fix (docs): `content/docs/frontend/plugins/plugin-grid.mdx` said
Space opens the record and Save / Save All save → corrected, and the
Batch Editing section says where it applies.
- `docs/qa/platform-checklist/areas/ux-conventions.json` ›
`ux-conventions.write-feedback`: variants[1] and knownGaps[1] told the
tester to press Save row / Save All → they now describe the autosave
marks and toast; revision 14 → 15 with its history row.
- nits: Esc in the editor now has the running-save check Esc on the
selected cell has (test added); the `Clause-②:` line names the new i18n
keys. Not changed: `rowPatches` entries are not pruned after a load
(memory only; a load's rows never match a stale `base`, and pruning by
`data` would drop patches for grouped rows read outside it).
- Left for S2, as the seat ruled: `ObjectGrid` hands the host's registry
to its own row load even without `cellSelection`, so a same-object child
grid under a `ListView` would miss one refresh during an outer grid's
write.
## Tests
New:
-
`ui/packages/components/src/__tests__/data-table-autosave-35685.test.tsx`
— a commit sends at once with no bar, no edit column and no amber row;
an unchanged commit sends nothing; a boolean on Space saves; a refusal
keeps the value and shows the reason; Esc in the editor and on the
selected cell restores; a refused cell and a later edit go as one
update; a commit during a running save waits; the open-record hint shows
(and does not, for a drawn field); a sorted row stays and a new load
re-sorts; a select-first table with `onBatchSave` only keeps the bar and
Save All sends the edit; Esc in the editor while the row saves leaves
the sent value alone; control without the provider keeps the save bar.
-
`ui/packages/plugin-grid/src/__tests__/ObjectGrid.autosave-35685.test.tsx`
— one guarded update and no read again although the write is announced
on the bus; the server's rewrite is drawn; the next save sends the
answered version; a 409 kept with "Overwrite anyway" writes with the
current version and reads no row again, while "Reload latest" reads
again; control: without `cellSelection` Save All re-reads.
- `ui/packages/plugin-grid/src/objectGridRowPatch-35685.test.ts` —
`mergeSavedRow`.
-
`ui/packages/plugin-list/src/__tests__/ListView.ownWrites-35685.test.tsx`
— the grid is handed the registry; a held record's write (on
`onMutation` and on the bus) re-reads nothing; control: another record's
write, or the same one after release, re-reads.
- `ui/packages/react/src/data-invalidation.test.ts` — `createOwnWrites`
hold / release / refcount, what it never absorbs, and
`useDataInvalidation` with and without it.
- Ablation: with `absorbs` forced to `false`, the ObjectGrid and
ListView "re-reads nothing" cases fail (2 of 5) and pass again once
restored. Review round: releasing the hold before the conflict dialog
again fails the "Overwrite anyway" case; `autosaves = selectFirst` (no
`onRowSave` check) fails the `onBatchSave`-only case; dropping the
running-save check from the editor's Esc fails the Esc case; each
restored passes.
Migrated (the behaviour they pinned is replaced by this card):
- `data-table-select-first-35684.test.tsx` › "Space on a selected cell
opens the record" → now asserts Space is not prevented, opens no record
and opens the editor with a space (voided by the maintainer's statement
above).
- `data-table-select-first-35684.test.tsx` › the edit-only trailing
column describe ("drawn only while a row has changes") → "no edit-only
column, ever": none at rest, none after a commit (which calls
`onRowSave` once), plus its control.
- `app-shell/src/views/ObjectView.rowOpensNothing-33317.test.tsx` and
`ObjectView.listOnlyRecordPage-33219.test.tsx` › the helper
`openWithSpace` (Space on a selected cell as "the list's other way to
open a row") → `openWithTap`, a touch tap on the cell, which still opens
the record. The negative cases (`preventNavigation: true`, `mode: none`,
a list-only object) still assert that path opens nothing, and the two
CONTROL cases that a tap opens the drawer. Found red on CI at `9970dffd`
(Test UI 1/16 and 6/16), fixed at `f836ec36`.
Voided: none beyond the Space assertion above.
## Verification
- `vitest` (from `ui/`): every `components` table/grid/cell test file,
all of `plugin-grid`, all of `plugin-list`, and
`react/src/data-invalidation.test.ts` — 509 files, 4805 passed, 7
skipped, 0 failed (re-run on the review-round head)
- `type-check` (`tsc --noEmit` and the test tsconfig) for
`@object-ui/components`, `@object-ui/react`, `@object-ui/plugin-grid`,
`@object-ui/plugin-list`: clean. `eslint` on every changed file: 0
errors.
- `node scripts/pm/dispatch-gates.mjs --commands`: 74 derived families
on the review-round head (the docs and checklist edits add 32), all run,
all exit 0; `--ran` reconcile: 74 derived, 74 run, 0 NOT-MEASURED, 0
UNRUN. `node scripts/pm/overlap-check.mjs`: VERDICT clean (merges with
`main` and with #35856, which shares the locale files).
- Changed lines 1518 vs the 3000 threshold: under.
- **Browser, before / after** — `examples/app-showcase` (`objectstack
dev --seed-admin`, own port and DB) with the `ui/apps/console` Vite dev
server over it, headless Chromium 1600×1000, zh-CN. Before = the changed
`ui/` sources checked out from the merge base; after = this head.
- Before: a committed name edit is staged (save bar "全部保存 (1)", amber
row, no request); pressing Save sends the PATCH and then re-reads the
whole page (`GET /api/v1/data/showcase_project?…top=50…`); Space on a
selected name cell opens the record.
- After: a committed name edit sends one `PATCH` with that field and
nothing else (no list read), the cell shows the check mark, no save bar.
Project end date set before the start date: `400` with the cross-field
reason naming `start_date`; the cell keeps "2000年1月1日" and the notice
says 「保存失败: 结束日期不能早于开始日期。」 with 「打开记录完成修改」. A budget edit on that row
then sends `{"end_date":"2000-01-01","budget":123456}` as one PATCH. Esc
on the end-date cell restores "2027年1月19日" and the notice goes. Space on
a selected name cell opens its editor with " " and the URL does not
change. A task title typed with surrounding spaces is trimmed by the
showcase's `beforeUpdate` hook and the cell shows the trimmed answer.
Sorted by name, a row renamed from "Data Platform" to "Zeta Platform"
stays in its place with no list read; after a reload it moves to its
sorted place.
- Not measured: Safari / WebKit (no WebKit build in the container); the
409 dialog in the browser (covered by the existing conflict tests,
unchanged here).
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the changed
files: 0 errors)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English. (the 维护者速读 block and
the maintainer's quote are Chinese by the maintainer's standing rule)
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01L6bhgUYnzYCcbcpABdW7ps
<!-- signed: repo:objectstack#1 · os-sales ·
session_01L6bhgUYnzYCcbcpABdW7ps -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent eb9f8ed commit fac1e7d
29 files changed
Lines changed: 1468 additions & 92 deletions
File tree
- .changeset
- content/docs/frontend/plugins
- docs/qa/platform-checklist/areas
- ui/packages
- app-shell/src/views
- components/src
- __tests__
- context
- renderers/complex
- i18n/src/locales
- plugin-grid/src
- __tests__
- plugin-list/src
- __tests__
- react/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
377 | 378 | | |
378 | 379 | | |
379 | 380 | | |
380 | 381 | | |
381 | 382 | | |
382 | | - | |
383 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
384 | 398 | | |
385 | 399 | | |
386 | 400 | | |
| |||
419 | 433 | | |
420 | 434 | | |
421 | 435 | | |
422 | | - | |
423 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
424 | 441 | | |
425 | 442 | | |
426 | 443 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
| 237 | + | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
294 | | - | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
295 | 296 | | |
296 | | - | |
297 | | - | |
298 | | - | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
299 | 301 | | |
300 | 302 | | |
301 | 303 | | |
| |||
333 | 335 | | |
334 | 336 | | |
335 | 337 | | |
336 | | - | |
| 338 | + | |
337 | 339 | | |
338 | 340 | | |
339 | 341 | | |
| |||
348 | 350 | | |
349 | 351 | | |
350 | 352 | | |
351 | | - | |
| 353 | + | |
352 | 354 | | |
353 | | - | |
| 355 | + | |
354 | 356 | | |
355 | 357 | | |
356 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
292 | 293 | | |
293 | | - | |
294 | | - | |
295 | | - | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
296 | 298 | | |
297 | 299 | | |
298 | 300 | | |
| |||
313 | 315 | | |
314 | 316 | | |
315 | 317 | | |
316 | | - | |
| 318 | + | |
317 | 319 | | |
318 | 320 | | |
319 | 321 | | |
| |||
385 | 387 | | |
386 | 388 | | |
387 | 389 | | |
388 | | - | |
| 390 | + | |
389 | 391 | | |
390 | 392 | | |
391 | 393 | | |
| |||
412 | 414 | | |
413 | 415 | | |
414 | 416 | | |
415 | | - | |
| 417 | + | |
416 | 418 | | |
417 | 419 | | |
418 | 420 | | |
419 | | - | |
| 421 | + | |
420 | 422 | | |
421 | 423 | | |
422 | | - | |
| 424 | + | |
423 | 425 | | |
424 | 426 | | |
425 | 427 | | |
| |||
0 commit comments