Repository navigation
Commit d8b15b5
Fixes #35689 — slice B (groups and totals after a save). Slice A (touch,
accessibility, checked rows) landed earlier on its own PR, so nothing
else on the card is left.
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
列表页按阶段分组时,把一条的阶段从甲改成乙:停在这一行时它不动,点到别的行后它出现在乙组,两组的条数和金额小计都对;改金额后分组小计和表尾合计马上更新。
- 列表行内编辑重做专题的最后一块(分组与合计随保存更新),这张卡至此做完。
- 出错时最坏是分组小计或表尾合计显示旧数字、或这一行要刷新后才换组,保存的数据本身不受影响;可以直接撤回。
- 无
## What changes
Measured first on `origin/main` 285ad8d, in a list that selects a cell
first (the list page's grid), with the card-named pins below run against
the unchanged source:
| Card item | Server grouping | Browser grouping | Premise |
|:---|:---|:---|:---|
| A row whose stage changed moves to its new group after the user leaves
the row | did not move | did not move | holds: broken |
| Group counts and amount subtotals after the save | not refreshed | not
refreshed | holds: broken |
| Footer total, flat grid whose rows are the whole set | not refreshed |
n/a | holds: broken |
| Footer total, grid paged on the server (whole-set figure) | already
re-read after a write | n/a | false: works on main, pinned only |
Why: a select-first save redraws only its own row (the row patches of
#35685) and the list lets its own write go by on the bus, so nothing is
read again. The groups, the group headers' numbers and the footer's row
figures read the rows as loaded, not as saved. The whole-set footer
listens to the bus itself, so it already re-asked.
What this PR does, all in `@object-ui/plugin-grid`:
- **The figures read the saved rows.** `rowsAsSaved` (in
`objectGridRowPatch.ts`) gives the rows with each saved row in place of
the one read, while that read is the one held. The footer reads it, so a
flat grid's total includes the saved value at once. A grid that groups
the rows it was handed buckets it, so its counts and subtotals follow
the save.
- **A row whose save changed a grouping field is held in its group until
the row is left.** `writeRowInPlace` notes such a record in
`heldInGroup`. The browser bucketing reads that record as it was loaded
(it stays in its group, counted and summed there). `onCellSelect` on a
cell of another row lets it go: the browser bucketing then moves it, and
a server-grouped grid reads its group headers and open groups' rows
again (`regroupNonce`). A cell of the same row does not let it go. Any
later save on a held row waits with it.
- **Any other save in a server-grouped grid re-asks only the headers**
(`savedFigureNonce`), so subtotals update at once and no row is read
again. `objectGridGrouping.ts` now keys the header query on that nonce
and the row pages on `regroupNonce` alone.
- A grid without the select-first model still reads everything again
after each save, as before (control pin).
Docs: `content/docs/frontend/plugins/plugin-grid.mdx` gains one bullet
under the per-cell save section. Changeset: `@object-ui/plugin-grid`
patch.
## Tests
One new top-level describe in the component's existing select-first save
harness, `ObjectGrid.autosave-35685.test.tsx`: "ObjectGrid — groups,
subtotals and the footer total after a cell save (objectstack#35689)".
It covers both grouping paths: the server, where the grid asks its own
group headers and group pages, and the browser, where it buckets rows a
host hands it.
- Card line 「离开这一行后它出现在乙组,两个组的条数和金额小计正确」, on each path: a stage pasted
from Prospect to Won keeps the row in Prospect, with both groups at
their old figures. A click on another cell of the same row keeps it
there too. A click on a cell of another row moves it to Won, and the
groups read Prospect 1 · 100 and Won 2 · 80.
- Card text 「分组小计…随保存更新」, on each path: an amount saved is in its
group's subtotal at once. No row is read again. A server-grouped grid
asks its headers exactly once more, and a browser-grouped one asks
nothing.
- Card line 「表尾合计在改了金额后更新」: in a flat grid whose rows are the set, the
footer sum goes from 180 to 200. In a grid paged on the server, the
whole-set footer is read again and reads 200 (this holds on main and is
pinned only).
- Control: without `cellSelection`, a write on the bus re-reads the
grouped grid at once.
Ablations: one run per leg through `scripts/ablation-replace.mjs`. Every
anchor hit x1 and went to x0, and every restore came back to the HEAD
blob `f5aebf14` with `git diff HEAD` empty. The suites import the grid
by relative path (source), so no dist leg was owed:
| Leg | Mutation | Red |
|:---|:---|:---|
| A1 | `onCellSelect` no longer lets a held row go | 2: the move pin on
both paths |
| A2 | no header re-ask on a save | 1: server subtotal |
| A3 | the grouping reads the loaded rows | 2: browser move and browser
subtotal |
| A4 | the footer reads the loaded rows | 1: flat footer |
| A5 | a held row is bucketed as saved | 1: browser hold before leaving
|
<details><summary>Readings (all through
scripts/pm/os-verify-lock.sh)</summary>
- On `origin/main` 285ad8d before any source edit, the new describe
gave 5 failed and 2 passed (the paged footer and the control). The
failures: Won expected Bolt and Cord, got Cord only (both paths); the
subtotal stayed 2 · 150 (both paths); the footer stayed Sum: 180.
- At e96aa67 (after merging origin/main with #36332 and #36396): `pnpm
turbo run build --concurrency=2 --filter='@object-ui/plugin-grid^...'
--filter='@objectstack/client-react...'`: 54 successful. Then `pnpm
--filter @object-ui/plugin-grid run type-check` (script echoed): exit 0.
Then `pnpm --dir ui exec vitest run --maxWorkers=2
packages/plugin-grid/`: Test Files 304 passed (304), Tests 2706 passed
(2706). And `pnpm --dir ui exec vitest run --maxWorkers=2 scripts/`:
Test Files 172 passed, 2 skipped; Tests 5127 passed, 2 skipped; exit 0.
- At 1285fe4 (the final head; it only moves the new describe above the
state-machine block, so it does not collide with an open PR's append at
the end of the file): the harness gave Test Files 1 passed (1), Tests 29
passed (29), VERDICT command-exit 0. `pnpm check:nul-bytes` exit 0.
</details>
<details><summary>Gates</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at e96aa67 derived 72 families (6 paths vs
merge base d8628ac). All ran with exit 0. Three needed a second
attempt: `check:skill-examples` first exited 3 because client-react had
no dist (built, then exit 0); `check:type-check-debt` first exited 3
because the lock was busy (run under the lock, exit 0, 0 raw tsc
errors); the ui `scripts/` suite first got no turn on the lock (exit
99), and its reading is above.
- `--ran`: 72 derived, 72 run, 0 NOT-MEASURED, 0 UNRUN, with every exit
code recorded.
- `node scripts/pm/overlap-check.mjs` at 1285fe4: VERDICT clean exit 0,
against origin/main 7ae5e07 and 4 open heads (#36453, #36438, #36357,
#36316).
</details>
## Acceptance notes
- "Leaving the row" means selecting a cell of another row (a click, the
arrow keys, Tab across the row's end). Escape, or a click outside the
grid, keeps the row selected, so it stays in its group until another row
is selected or the list loads again.
- When a server-grouped grid regroups on leaving a row, it reads the
open groups' rows again, so a group pager turned past page 1 starts over
at page 1, as on any refresh.
- A held record stays noted after a later full load. The next time a row
is left, the groups are read one extra time. That read is harmless.
## Verification
Files to read first, by risk:
1. `ui/packages/plugin-grid/src/ObjectGrid.tsx`: `noteSavedPlace`,
`leaveHeldRows`, and the `savedData` and `groupedData` memos.
2. `ui/packages/plugin-grid/src/objectGridGrouping.ts`: the header and
row reload keys.
3. `ui/packages/plugin-grid/src/objectGridRowPatch.ts`: `rowsAsSaved`.
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-grid/src/__tests__/ObjectGrid.autosave-35685.test.tsx`.
Expect 29 passed, including the seven under "(objectstack#35689)".
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 595844b commit d8b15b5
6 files changed
Lines changed: 356 additions & 8 deletions
File tree
- .changeset
- content/docs/frontend/plugins
- ui/packages/plugin-grid/src
- __tests__
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
466 | 472 | | |
467 | 473 | | |
468 | 474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
874 | 875 | | |
875 | 876 | | |
876 | 877 | | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
877 | 881 | | |
878 | 882 | | |
879 | 883 | | |
| |||
986 | 990 | | |
987 | 991 | | |
988 | 992 | | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
989 | 1012 | | |
990 | 1013 | | |
991 | 1014 | | |
| |||
1470 | 1493 | | |
1471 | 1494 | | |
1472 | 1495 | | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
1473 | 1499 | | |
1474 | 1500 | | |
1475 | 1501 | | |
| |||
1495 | 1521 | | |
1496 | 1522 | | |
1497 | 1523 | | |
1498 | | - | |
| 1524 | + | |
1499 | 1525 | | |
1500 | 1526 | | |
1501 | 1527 | | |
| |||
1885 | 1911 | | |
1886 | 1912 | | |
1887 | 1913 | | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
1888 | 1919 | | |
1889 | 1920 | | |
1890 | 1921 | | |
1891 | | - | |
| 1922 | + | |
1892 | 1923 | | |
1893 | 1924 | | |
1894 | | - | |
| 1925 | + | |
1895 | 1926 | | |
1896 | 1927 | | |
1897 | 1928 | | |
| |||
1908 | 1939 | | |
1909 | 1940 | | |
1910 | 1941 | | |
1911 | | - | |
| 1942 | + | |
1912 | 1943 | | |
1913 | 1944 | | |
1914 | 1945 | | |
| |||
3100 | 3131 | | |
3101 | 3132 | | |
3102 | 3133 | | |
| 3134 | + | |
3103 | 3135 | | |
3104 | 3136 | | |
3105 | 3137 | | |
3106 | 3138 | | |
3107 | 3139 | | |
3108 | 3140 | | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
3109 | 3164 | | |
3110 | 3165 | | |
3111 | 3166 | | |
| |||
0 commit comments