Repository navigation
Commit 69c3dc4
fix(fields): a dependsOn lookup filters by a populated parent's id, not "[object Object]" (#36938)
Fixes #36837
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户在记录详情页(以及编辑弹窗)里点一个依赖上级查找字段的选择器(例如报价单的「联系人」按所属客户过滤)时,原来永远显示「未找到选项」,现在能列出该客户下的联系人。
- 属于表单级联选择(依赖字段过滤)这一核心能力,替产品负责人报告的报价单场景解决。
- 若有误,最坏情况是依赖过滤取错值导致选择器为空,与修复前相同;改动只在一处,可直接撤回。
- 无。
## What changes
A lookup with `dependsOn` naming another lookup builds its candidate
filter from the record the host hands it (`dependentValues`). A record
page hands the record as the server returned it, so the parent lookup
arrives **populated** (`{ id, name, … }`). The one place that turns that
record into the filter, `LookupField`'s `dependentFilter` memo, did
`String(v)` on it. The request then carried `["crm_account","=","[object
Object]"]` and the picker never matched.
`dependentFilter` now collapses the parent value through
`collapseReference`. That is the rule `lookupRecordReference.ts` already
applies to `{ $record }` filter comparands ("an expanded row collapses
to its id"), now exported so both candidate-filter readers share it. It
is fixed at that one producer. All four candidate surfaces read the same
memo, so all four are fixed: the quick-select popover, the Level-2 table
picker, the PeoplePicker and the create-new seed (`initialValues` /
inline `create`). The fix applies whatever the host is: detail inline
edit, header highlight, in-place editor or the record form. A bare-id
parent is unchanged.
Files:
- `ui/packages/fields/src/widgets/LookupField.tsx`: the
`dependentFilter` memo collapses each parent value; an import is added.
- `ui/packages/fields/src/widgets/lookupRecordReference.ts`:
`collapseReference` is exported and its doc names both readers.
- `ui/packages/fields/src/widgets/LookupField.dependsOn.test.tsx`: a new
top-level `describe` in the existing dependsOn harness.
- `.changeset/36837-dependson-lookup-id.md`: `@object-ui/fields` patch.
## Tests
- New pin "a populated dependsOn parent scopes by its id
(objectstack#36837)":
- The populated parent `{ account: { id: 'a1', name: 'Acme' } }` must
put `$filter.account === 'a1'` on every `find` call, and the list must
show only that account's contact.
- Control: the same parent passed as a bare id sends the identical
filter.
- Red before the fix: `expected '[object Object]' to be 'a1'`, the
card's captured request reproduced (1 failed | 10 passed).
- Green after the fix: the five dependsOn / record-reference LookupField
files pass, 39/39. The whole `ui/packages/fields/` suite passes at
e19a6b2: Test Files 326 passed | 1 skipped, Tests 4982 passed | 7
skipped.
- Ablation, one run at e19a6b2 through `scripts/ablation-replace.mjs`:
- The mutation dropped `collapseReference(...)` from the memo and
landed: anchor 1 → 0, blob c7c449f → 71cd8a0.
- The new pin went red with `Received: "[object Object]"`.
- The restore was verified: the blob equals HEAD's c7c449f and `git diff
HEAD` is empty.
- The test imports `./LookupField` from source, so no dist rebuild was
needed.
## Acceptance notes
- The `[object Object]` family the card names is in separate code. The
kanban grouping (#36430) and the drill dialog (#36507) live in
`plugin-kanban` / `plugin-dashboard`, and neither reads
`dependentFilter` or `collapseReference`. They are not touched here.
- The gate check (`dependenciesMissing`) already treats a populated
object as "present", so it needed no change.
- I kept the edit in the picker component to one line plus one import,
because #36832 is also reworking the lookup picker.
## Verification
First file to read: `LookupField.tsx`, the `dependentFilter` memo. It is
the only risky part of the change.
Two-minute check: `pnpm --dir ui exec vitest run
packages/fields/src/widgets/LookupField.dependsOn.test.tsx` should show
11 passed.
**Seat-written open.** Seat `repo:objectstack#4` (os-justin,
`session_01QSeKYpEsWWE9Y5YtSsDgqZ`) opened this draft on the
maintainer's ruling in the seat session, verbatim 「一选1+」 (2026-11-24):
option 1+ — the seat performs only the writes the dev session's
permission classifier refused, each checked against the branch; pull
requests stay draft; no standing allow rule is added (evidence card
#36936). Refused once in dev session `session_01QSeKYq2vSKPUSvT9fXdzEY`,
reason `[Undermining Oversight]`: `node
scripts/pm/fleet-write/dispatch.mjs --repo objectstack-ai/objectstack
--actions-file FILE` carrying this one `pr_create`. Title and body above
are the dev's text, unchanged; branch head checked at `e19a6b25` (4
files, +84 −3; the `LookupField.tsx` change read against the body).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QSeKYq2vSKPUSvT9fXdzEY)_
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 129e637 commit 69c3dc4
4 files changed
Lines changed: 84 additions & 3 deletions
File tree
- .changeset
- ui/packages/fields/src/widgets
| 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 | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
865 | 866 | | |
866 | 867 | | |
867 | 868 | | |
868 | | - | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
869 | 872 | | |
870 | 873 | | |
871 | 874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
126 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
127 | 131 | | |
128 | 132 | | |
129 | 133 | | |
| |||
0 commit comments