Repository navigation
Commit 5345905
<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XURgXCZHcjPoyo5g9cMEATi)_
Part of #35689 — slice A (touch, accessibility, checked rows). Slice B
(a row moving to its new group, group subtotals and the footer total
refreshing after a save) stays on the card for its own PR.
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
平板上点列表的一行只会打开记录,不会误进格子编辑;读屏软件移到不能改的格子会读出「只读」(审批锁在选中后才查到时也会立刻读出),格子保存后会读出「已保存:字段名」,失败时读出原因;其余用户无感。
- 列表行内编辑重做专题的收尾(无障碍与触屏部分),分组移动与合计刷新另开一个 PR。
- 出错时最坏是读屏软件少读或多读一句、平板上点到编辑按钮没反应,不影响保存的数据;可以直接撤回。
- 无
## What changes
Measured on `origin/main` before any edit (the dispatch's six mechanism
assumptions):
1. **Touch.** A touch tap on a cell opens the record and never selects
or edits (`isTouchPress`, from #35684): holds, pinned. One gap measured:
a lookup cell's edit button (the pencil) is drawn at `opacity-0` once
any pointer enters the cell and is still hit-testable, so a tap on the
right edge of an unselected lookup cell landed on the invisible button
and **opened the editor in place**. Fixed in `CellEditButton`: a finger
entering an unselected cell does not draw the button, and a touch click
on one drawn earlier for a mouse does nothing (the row ignores a click
on a button). The press is read by its own click only, then cleared, so
a later click with no pointer of its own (assistive tech) edits as
before. The explicit edit entry on touch is the record page (a tap
beside the button opens it), per the card's 「通过记录页或显式的编辑入口」.
2. **`aria-readonly`.** Absent. Now, only when the table is
`role="grid"`, a data cell that opens no editor carries
`aria-readonly="true"`, and so does the type-catcher input that holds
focus in the selected cell (the element a screen reader lands on). Every
cell reads the table's own facts (`editable`, the column,
`isRowEditable`); the selected cell adds the host's (`describeCell`).
The host's answer is **asked as the cell becomes selected and kept in
state** (`selectedHostReadOnly`), asked again only when the selected row
is re-read or the host hands the table a new `GridCellSelection` value,
so it is not asked per render for a host whose value is stable.
`describeCell`'s TSDoc now says exactly that: asked when the reader acts
on a cell, once as a cell becomes selected, and again when its row is
re-read or the provider's value is a new object; the value's identity is
part of the contract, so a host keeps it stable (memoised) or the
selected cell is asked on every render.
- In the list (`ObjectGrid`), the host value is now memoised on what its
cell facts read (fields, object, permissions, the view's `editable`, the
update verdicts, the approval locks, the page's record ids, the
language), so it is new only when an answer can have changed; the commit
question and the chip opener read the latest render through a ref.
- `useRowApprovalLocks` re-renders its host when a lock read answers
(and when the answers are dropped on an invalidation): `isLocked` and
the hook's value are new exactly then. So a lock answered after the
select-time ask is said on the selected cell at once, without the reader
moving, both ways (locked by the service, or a pending `approval_status`
the service says is not locked).
3. **Live region.** Before: a per-cell `role="status"` span mounted with
its state, its words only in `aria-label`, plus `role="alert"` on
failure. A region that mounts with its content is often not announced,
and a label is not live content. Now one persistent visually hidden
`aria-live="polite"` region per table that saves per cell (`autosaves`),
drawn for the table's whole life; a successful save writes "Saved:
COLUMN" into it (new key `table.cellSavedAnnouncement`, all eleven
packs), each saying in a node of its own so the same words twice are
said twice. Cells saved together are joined with the pack's list
punctuation (`validation.formInvalidJoiner`, the key the form's field
lists use: `、` in ja and zh), and a column with no header is never named
by its key (the region then says `table.cellSaved`, "Saved"). A failure
stays with the existing cell alert, said once; the region drops the
earlier "saved". The per-cell mark becomes `role="img"` with its
existing label: named, never live, so no duplicate announcement.
4. **Focus after a picker panel closes** (`placement="below"`):
measured, it already returns to the cell by Esc and by a pick
(`focusSelectionRef`, #35688). Pinned, no source change.
5. **Selection frame contrast** (`border-2 border-primary`, WCAG 1.4.11,
3:1 needed): passes everywhere, no change. Token arithmetic (sRGB
relative luminance) on the shipped themes:
- Console light (`--primary` 211 100% 50% on `--background` white):
3.97; on the hover row (muted/40) 3.74; on a checked row (primary/5)
3.73; on a checked hovered or active-record row (primary/10) 3.49; on
full muted 3.40.
- Console dark (211 100% 60% on 240 6% 6%): 6.34; hover 5.83; checked
6.03; checked hover/active 5.67.
- `@object-ui/components` default theme: 17.84 light, 19.09 dark, at
least 14.53 on any row state.
6. **Selection.** `commitCellValue` stages one cell and never reads
`selectedRowIds`; `selectionResetKey` moves only on bulk actions and
refresh: holds, pinned.
### Review round (L1 7076074435, L2 7076070602)
| Item | Resolution | Commit |
|:---|:---|:---|
| S1 (L1, L2): `describeCell` asked per render | Asked at selection,
kept in state; re-asked only on a re-read row or a new host value;
`ObjectGrid`'s value memoised so it is new only when its facts can
change. TSDoc kept as is. | `1733276c`, `6bc85294` |
| S2 (L2): a lock answered after the select-time probe |
`useRowApprovalLocks` re-renders on an answer; re-applied on main's
batched lock read (#36295) in the merge | `1733276c`, `65b9199f` |
| N1: touch-tap comment, `pressedByRef` never reset | Comment says the
tap does nothing on the button; the press is cleared by the click that
reads it | `1733276c` |
| N2: hard-coded `', '`, raw `accessorKey` |
`validation.formInvalidJoiner`; a header-less column is left unnamed |
`1733276c` |
| N3: claim's file surface | The final file surface is in the dev report
for the seat to amend the claim | report |
| L1-d 7078101760 item 1, L2 R1 (7077725274): TSDoc still said "never
per render" | `describeCell` TSDoc says when the table asks it and that
the provider value's identity matters; the two data-table comments that
echoed it aligned | `69919545` |
## Tests
New card-named describes, each in the component's existing harness file:
- `data-table-select-first-35684.test.tsx`: a touch tap opens the record
and a touch double-tap neither selects nor edits; a tap on an unselected
lookup cell's edit button edits nothing (control: the mouse's click
edits); after such a tap, a click with no pointer of its own edits; the
selected read-only cell carries `aria-readonly` on the cell and its
focus, an editable one none; **the host's facts are asked as the cell is
selected and not again across three re-renders, and a new host value is
asked again and turns `aria-readonly` on where the selection is**; a
table that edits nothing marks every cell; control: outside the grid no
`aria-readonly`.
- `data-table-autosave-35685.test.tsx`: the region is there and silent
before any save, says "Saved: Name" after one, a second saying is a new
node, saving is not said, and the table holds exactly one live element;
cells saved together read `已保存:Stage、Name` in zh; a header-less column
reads "Saved"; a refused save is said by the cell alert alone and the
region empties; control: no region without per-cell save. With two rows
checked, a cell edit sends one update of that one cell and both checks
stay.
- `data-table-keys-35687.test.tsx`: a picker panel under the cell hands
focus back to the cell on Esc and on a pick.
- `ObjectGrid.cellSelection-35684.test.tsx`: with the page's lock read
held open, a row the service says is locked turns `aria-readonly` on
once the read answers, and a row whose `approval_status` stands in as
locked turns it off once the service says it is not, both while the cell
stays selected.
Readings, all through `scripts/pm/os-verify-lock.sh`. Head `69919545`
changes only the TSDoc and two comments over `65b9199f`:
<details><summary>At 6991954 (TSDoc round)</summary>
- Closure build `pnpm --workspace-concurrency=2 --filter
'@object-ui/components^...' build`, then `pnpm --filter
@object-ui/components run type-check`, then the three data-table
harnesses and `ObjectGrid.cellSelection-35684`: Test Files 4 passed (4);
Tests 116 passed (116); VERDICT command-exit 0.
- `dispatch-gates --commands` re-derived: the same 42 families as at
65b9199; `pnpm check:nul-bytes` exit 0. The other families were not
re-run locally for a comment-only delta; CI runs them (below).
</details>
<details><summary>Type-check, the touched harness files and the affected
packages' suites at 65b9199</summary>
- Closure build `pnpm --workspace-concurrency=2 --filter
'@object-ui/plugin-grid^...' build`, then `pnpm --filter
@object-ui/components run type-check`, `pnpm --filter
@object-ui/plugin-grid run type-check`, `pnpm --filter @object-ui/i18n
run type-check`: VERDICT command-exit 0 (each script name echoed in the
log).
- Six harness files (the three table harnesses,
`ObjectGrid.cellSelection-35684`, `ObjectGrid.autosave-35685`,
`ObjectGrid.requiredPrompt-35956`): Test Files 6 passed (6); Tests 154
passed (154).
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-grid/
packages/components/ packages/i18n/`: Test Files 910 passed, 1 skipped
(911); Tests 9532 passed, 37 skipped (9569); VERDICT command-exit 0.
- `pnpm --dir ui exec vitest run --maxWorkers=2 scripts/` (derived
family): Test Files 172 passed, 2 skipped (174); Tests 5127 passed, 2
skipped (5129); exit 0.
</details>
<details><summary>Ablations this round (one each, through
`scripts/ablation-replace.mjs`: anchor hit once, blob changed, restored
to the HEAD blob, `git diff HEAD` empty)</summary>
The suites read `data-table.tsx` and the hook from source (the ui vitest
config aliases `@object-ui/components` to `src`; the grid test imports
the hook relatively), so no rebuild per leg was owed.
- A1, the per-render ask put back (`cellReadOnly` calling
`readOnlyReasonOf` on the selected cell): 1 red, "the host's facts are
asked as the cell becomes selected, never per render" (expected 2 calls,
got 5); the other aria pins stay green, as they should.
- A2, the hook's re-render on an answer removed: 2 red, both lock-answer
pins in `ObjectGrid.cellSelection-35684`.
- A3, the press not cleared by its click: 1 red, "after a tap on the
edit button, a click with no pointer of its own (assistive tech) edits".
- A4, the Latin comma put back: 1 red, the zh list-punctuation pin.
- A5, the key fallback put back: 1 red, "a column with no header is not
named by its key".
- Restore proof after the run: `data-table.tsx` blob b7a0e66 and the
hook blob 271953e, each equal to HEAD; `git diff HEAD` 0 lines.
</details>
<details><summary>Earlier readings (previous dev, heads e276bef and
2c776b4)</summary>
- At e276bef: components and i18n type-check exit 0;
`packages/components/ packages/i18n/` Test Files 608 passed, 1 skipped;
`scripts/` 172 passed, 2 skipped files.
- Ablations then: cell `aria-readonly` removed, 2 red; the region's
success saying removed, 2 red; the touch guard removed, 1 red.
</details>
## Acceptance notes
- Not done here, by the card's split: slice B (a row moving to its new
group after a save, group subtotals and the footer total refreshing)
follows on its own PR.
- `aria-readonly` on cells other than the selected one reads the table's
own facts only (`editable`, the column, `isRowEditable`); the host's
per-cell facts (`describeCell`: field read-only, permission, approval
lock) are asked of the selected cell alone, because the table asks
`describeCell` only at the moments its TSDoc names, never for every
cell. A screen reader moving cell to cell always lands on the selected
cell, so the acceptance line holds; a reader browsing the table in its
virtual mode hears the coarser answer on cells it does not select.
- While the selected row's lock read is on the wire, the selected cell's
`aria-readonly` reads the `approval_status` column (the hook's fail-open
stand-in) and changes when the read answers; Enter or F2 in that window
waits for the read (#36295) and says the reason.
- The `ObjectGrid` memo is not pinned by a test of its own (its call
count is internal to the host); the table-level pin holds the table to
"never per render" for any host whose value is stable.
- "A touch never edits in place" is a fact of the select-first model
(`cellSelection`): there a click only selects, so `singleClickEdit` is
never read, and the touch pins in
`data-table-select-first-35684.test.tsx` already run with
`singleClickEdit: true`. `ObjectGrid` passes `singleClickEdit:
schema.singleClickEdit ?? true` on main today; #36357 (read at
`579f99ae`) also edits `ObjectGrid.tsx` (`hostCellSelection =
cellSelectionProp ?? inlineEditable`, `singleClickEdit: true`) and
`ObjectGrid.cellSelection-35684.test.tsx`; it makes every grid that
renders editable select-first, so this behaviour extends to them and no
pin here flips; `node scripts/pm/overlap-check.mjs --pr=36357` on
6991954: merges cleanly, VERDICT clean. The one residual is a host
passing `cellSelection={false}` explicitly (none in-tree). A grid on the
older click-to-edit model (no `cellSelection`, `singleClickEdit` true)
still edits on a touch tap, as it did before this PR; that model is
outside this slice.
- A tap that lands on a lookup cell's edit button drawn earlier for a
mouse (a hybrid device) now does nothing at all rather than editing; the
row's click handler ignores clicks on buttons, so the tap does not open
the record either. A finger alone never draws the button.
- Real screen-reader output (VoiceOver, NVDA) and a real iPad were not
exercised; the pins are jsdom, and the claim about a region that mounts
with its words is the general live-region behaviour, not a measurement
here.
- Selection frame contrast: no change needed; the readings are in What
changes.
## Verification
Read first (risk order):
1. `ui/packages/plugin-grid/src/ObjectGrid.tsx`, the `gridCellSelection`
memo and its dependency list: a missing dependency would leave the
selected cell's `aria-readonly` stale until the reader moves (act-time
reads stay fresh either way).
2. `ui/packages/components/src/renderers/complex/data-table.tsx`, the
`selectedHostReadOnly` layout effect and the `cellReadOnly` line in the
body-cell map.
3. `ui/packages/plugin-grid/src/hooks/useRowApprovalLocks.ts`, the
`answerSeq` bump in the read's `finally` and on the invalidation reset.
Two-minute check: `pnpm --dir ui exec vitest run
packages/plugin-grid/src/__tests__/ObjectGrid.cellSelection-35684.test.tsx`,
expect every test passing, among them the two in "the selected cell says
a lock that answers after it was selected (objectstack#35689)".
<details><summary>Local gates (targeted, derived from the diff) at
65b9199</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 42 families (19 paths vs merge base
c448c61); all run, every one exit 0 (`check:query-options-erasure`
re-run without the loop's 300 s cap after the first try hit it: exit 0,
"ratchet holds"). `pnpm check:type-check-debt`: exit 0, "0 raw tsc
error(s) total". `--ran` reconciliation: 42 derived, 42 run, 0
NOT-MEASURED, 0 UNRUN, exit 0. ui i18n gates: `check:i18n-keys`,
`check:i18n-drift`, `check:i18n-dead-keys` exit 0. `pnpm
check:nul-bytes`: exit 0. `node scripts/pm/overlap-check.mjs` before
each push: VERDICT clean (at 65b9199 after merging origin/main, which
had conflicted on the lock hook and its test; at 6991954 against
origin/main ff60149 and 10 open heads, and with `--pr=36357`).
CI on 6991954: 45 success, 13 skipped, 0 failure (on 65b9199 before
it: 47 success, 15 skipped), among them Lint and Repo Gates, TypeScript
Type Check, Test Core, Governed Surface Queue Guard, Lint UI, Type Check
UI, Test UI (16/16 shards), Build and E2E UI, Live E2E UI, Dogfood
Regression Gate, Check Changeset, PR-body guards.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds)_
<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jUc3qp6bHKSWijbjds -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 761220c commit 5345905
20 files changed
Lines changed: 464 additions & 15 deletions
File tree
- .changeset
- ui/packages
- components/src
- __tests__
- context
- renderers/complex
- i18n/src/locales
- plugin-grid/src
- __tests__
- hooks
| 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 | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
78 | | - | |
| 83 | + | |
79 | 84 | | |
80 | | - | |
| 85 | + | |
81 | 86 | | |
82 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
| |||
403 | 411 | | |
404 | 412 | | |
405 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
431 | 433 | | |
432 | 434 | | |
433 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
504 | 507 | | |
505 | 508 | | |
506 | 509 | | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
113 | 121 | | |
114 | 122 | | |
115 | 123 | | |
| |||
0 commit comments