Repository navigation
Commit 6156fdd
fix(fields): a multi-record lookup column in the line-item grid reads its records, not "undefined", read-only and in list mode (#36728)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ852pUyi6G1KDP9T8JogHTeb)_
Fixes #36618
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户在只读的记录页、打印页或卡片式明细里查看明细行时,"可选多条关联记录"的那一列不再显示
undefined,而是逐个显示所关联记录的名称;单选的关联列外观不变。
- 属于体验专题的界面缺陷修复,替查看订单、报价这类带明细行单据的人解决看不懂的问题。
- 出错的话只是这一列显示不对,不影响保存的数据,可直接撤回。
- 无。
## What changes
The line-item grid renders a read-only `LookupField` at two sites: the
read-only table (`readonly` grid: read-only record page, print page) and
the list form-factor cell (`displayMode="list"`). Both built the
lookup's `field` without the column's `multiple`, while the editable
cell passes `multiple: c.multiple`. Without it, `LookupField` resolves
the stored id list as ONE id (`selectedOptions =
[resolveSelectedOption(value)]`) and its single-value read-only face
prints that option's missing label, which renders as "undefined".
- `ui/packages/fields/src/widgets/grid-field/GridFieldWidget.tsx`: both
read-only sites now pass `multiple: c.multiple`, read from the column
definition (as the card asks), never inferred from the value's shape.
The read-only face then draws one badge per related record.
- Changeset: `@object-ui/fields` patch.
No new prop, key or export. Single-record lookup columns are unchanged.
## Tests
New
`ui/packages/fields/src/widgets/GridField.multiLookupReadonly-36618.test.tsx`,
one case per site plus a control per site:
- read-only table: a cell holding `['p1', 'p2']` draws `Widget` and
`Gadget`, and the grid's text has no `undefined`;
- list mode: the same;
- control, each site: a single-record lookup column still draws its one
name.
Reverse verification (fix committed first; each site reverted on its own
with an anchored replacement whose hit count was checked, test run, then
`git checkout HEAD --` and `git diff HEAD` empty):
| Site reverted | Result |
|---|---|
| read-only table | `× read-only: a cell holding two product ids draws
both product names`; 3 others pass |
| list mode | `× list: a cell holding two product ids draws both product
names`; 3 others pass |
So each multi-value case pins its own site, and the controls pass both
ways.
<details><summary>Package runs at 418f177 (merged with main e343ab7;
the merge touched nothing under ui/packages/fields)</summary>
```
pnpm exec vitest run --root ../.. --maxWorkers=2 packages/fields/src/widgets/GridField
Test Files 21 passed (21)
Tests 272 passed (272)
os-verify-lock: VERDICT command-exit 0
pnpm --filter @object-ui/fields type-check (tsc --noEmit && tsc -p tsconfig.test.json)
exit 0
```
The dependency closure was built first (`pnpm --filter
'@object-ui/fields^...' build`, VERDICT command-exit 0).
</details>
<details><summary>Derived gate families (dispatch-gates --commands, 38
families, run on the same diff at 974437a3 before the merge with
main)</summary>
All 38 exited 0. `dispatch-gates --ran`: 38 derived, 38 run, 0
NOT-MEASURED, 0 UNRUN. Every family CI runs is read from this PR's
check-runs, not re-run locally.
</details>
## Acceptance notes
- Not measured in a browser: the showcase app has no line-item grid with
a multi-record lookup column to open. The jsdom pins render the real
`LookupField` against a data source and read the drawn names.
- An empty stored list (`[]`) still reaches the lookup branch in both
sites (the guard checks `null` and `''` only); with `multiple` passed it
draws the lookup's read-only empty face, not the grid's muted em dash.
Not pinned here, and what it drew before was not measured. Left as is:
the card asks only for `multiple`.
## Verification
Read first:
1. `ui/packages/fields/src/widgets/grid-field/GridFieldWidget.tsx`, the
two read-only `LookupField` sites (the only code change).
2. The new test file.
Two-minute check: `pnpm --dir ui exec vitest run
packages/fields/src/widgets/GridField.multiLookupReadonly-36618.test.tsx`
shows 4 passing; revert either `multiple: c.multiple` and its site's
multi-value case fails.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbYEoTneL1bdkVJrq2S)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent d24a502 commit 6156fdd
3 files changed
Lines changed: 97 additions & 2 deletions
File tree
- .changeset
- ui/packages/fields/src/widgets
- grid-field
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 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 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1280 | 1280 | | |
1281 | 1281 | | |
1282 | 1282 | | |
1283 | | - | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1284 | 1287 | | |
1285 | 1288 | | |
1286 | 1289 | | |
| |||
1389 | 1392 | | |
1390 | 1393 | | |
1391 | 1394 | | |
1392 | | - | |
| 1395 | + | |
| 1396 | + | |
1393 | 1397 | | |
1394 | 1398 | | |
1395 | 1399 | | |
| |||
0 commit comments