You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 99a0e4f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(ui): a lookup's group headers and filter options read the target's nameField, and the empty group is translated (#35140)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8AJJJRiYjshMUNgyMZSqBsr)_Fixes#35053
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- **改了什么**:列表按查找字段分组时的分组标题(服务端分组与客户端分组)、筛选器里查找字段的候选值,在查找字段未声明
`displayField` 时改用目标对象声明的 `nameField` 命名,不再显示原始记录
id;空值分组的标题改用网格已有的「空」文案(`grid.empty`),随语言翻译。
- **为什么改**:spec 对 `displayField` 的默认值写明是「被引用对象的
name/title」,单元格与记录页头早已这样做;这三处却只猜 `name/label/title`,目标对象以自动编号等字段为标题时(如
`DEAL-2026-0001`),中文用户看到的是一串 id 和英文的 `(empty)`。
- **风险与回滚**:只改显示文案,分组与筛选仍按 id;新增读取目标对象定义(每个目标对象一次,适配器有元数据缓存)。英文空分组从
`(empty)` 变为 `Empty`,位置不变。回滚即 revert 本 PR。
-
**先看**:`ui/packages/plugin-grid/src/useServerGrouping.ts`(标题读取处并行读目标定义)、`ui/packages/components/src/custom/filter-builder.tsx`(`LookupValuePicker`
改为存记录、渲染时算标签)、`ui/packages/core/src/utils/record-title.ts`(新增
`referencedRecordTitle`,从 `getRecordDisplayName` 拆出无兜底的一段)。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/plugin-grid/src/__tests__/lookupGroupNameField-35053.test.tsx
packages/components/src/__tests__/filter-builder-lookup-namefield-35053.test.tsx`,预期
10 个用例全绿(含 zh-CN 空分组显示「空」)。
- **需要你做的**:无,席位落地。
## What changes
- **One resolver.** `@object-ui/core` adds
`referencedRecordTitle(targetDef, record, displayField?)`: the lookup's
own `displayField`, then the target object's `getRecordDisplayName`
ladder (declared `nameField` first, ADR-0079), stopping short of the
`Record #ID` / `Untitled` floor and answering `undefined` there, so each
caller keeps its own face for an unnamed record. `getRecordDisplayName`
is split into the rungs above the floor (`recordTitleAboveFloor`,
module-private) plus the floor, so the two cannot drift; its behaviour
is unchanged.
- **Server-grouped headers** (`useServerGroupHeaders`): the label read
now reads the target's definition in parallel with the record read
(`readLookupTargetDef`) and names each id through
`referencedRecordTitle`. Before: `displayField`, else `name ?? label ??
title`, else the raw id.
- **Client grouping** (`useObjectGridGrouping`'s `groupValueFormatter`):
a lookup grouping field's expanded record is named through
`referencedRecordTitle` with the target definition
(`useLookupTargetDefs`, enabled only on the client path) and the field's
`displayField`. Before: the `displayField` was ignored and the `name ??
label ?? title ...` guess ran. `buildSegmentLabel`'s object arm, used by
the published `useGroupedData` with no formatter, now runs the same
resolver with no target definition (record-only ladder) instead of its
own key list.
- **Filter value picker** (`LookupValuePicker`): `displayField` no
longer defaults to `"name"`; the target definition is read through
`@object-ui/react`'s `useSettledSchema` (one read per picker mount), and
options plus the chosen value's chip are labelled at render through
`referencedRecordTitle`, so a definition that lands after the search
still names them. Options and selections stay keyed and written by id.
- **Empty group heading**: the literal `(empty)` is replaced by the
grid's existing empty-value key `grid.empty` (translated in all twelve
packs: `Empty`, `空`, ...), read inside `useGroupedDataInOptionOrder`
through `useGridTranslation`. No new locale key. The empty group keeps
its place in label order by its KEY, not its heading
(`compareGroupLabels`): first ascending, last descending, as the
untranslated heading always sorted.
## Tests
- New
`ui/packages/plugin-grid/src/__tests__/lookupGroupNameField-35053.test.tsx`:
per producer (server-grouped, client-grouped) a target with `nameField:
'deal_number'` and no name/label/title heads its groups with the deal
numbers; CONTROL that an explicit `displayField` still wins; two records
sharing one title stay two groups; zh-CN empty group reads `空` and keeps
its place.
- New
`ui/packages/components/src/__tests__/filter-builder-lookup-namefield-35053.test.tsx`:
options read the deal numbers and the picked value written is the id;
the chosen value's chip reads the deal number; CONTROL that an explicit
`displayField` wins.
- `record-title.test.ts`: four pins on `referencedRecordTitle`
(nameField, displayField wins, undefined where `getRecordDisplayName`
floors, record-only ladder without a definition).
- Updated pinned headings `'(empty)'` to `'Empty'` in
`groupSelectOptionOrder-11809`, `groupDateHeading-13234` and
`serverGroupingFieldSwitch-11574` (the ascending order controls there
stay green, which is the order-preservation evidence).
## Acceptance notes
- PM mechanism assumption measured: none of the three producers had the
target object's definition in hand. The grid loads only the grouped
object's definition (`objectFields`, which carries `reference` and
`displayField`, not the target's `nameField`); the lookup cell's
target-schema cache is private to `@object-ui/fields`, which
`@object-ui/components` cannot import (cycle). Cheapest correct path
taken: `dataSource.getObjectSchema(target)`, one per target per header
load / per change of the client grouping's target list / per picker
mount. The ObjectStack adapter serves repeat reads from its metadata
cache, and the lookup cells on the same screen already read the same
targets, so in the Console this is normally zero extra network requests.
- The published `useGroupedData` with no formatter now names an expanded
record by `referencedRecordTitle`'s record-only ladder: `name`,
`full_name`, `fullName`, `display_name`, `displayName`, `title`,
`subject`, `label`, then the `*_name` / `*_title` affix scan. The old
list put `label` before `title` and had no `subject` or affix leg.
- English readers now see `Empty` where they saw `(empty)`; that is the
grid's existing empty-value string, chosen over minting a new key per
the dispatch.
- Observation, not filed: `@object-ui/fields`' private
`resolveLookupRecordName` performs the same operation by calling
`getRecordDisplayName` and string-matching the floor; it could call
`referencedRecordTitle` instead. Outside this claim's file surface.
## Verification
<details><summary>Ablation, one leg per producer plus the empty label
(scripts/ablation-replace.mjs, restore proven blob == HEAD each time;
vitest resolves the ui packages from src)</summary>
- server: `referencedRecordTitle(targetDef, rec, ...)` replaced by the
old `displayField ?? name ?? label ?? title` read: 2 failed (the
nameField pin and the zh-CN pin, which also reads the deal numbers); the
`displayField` CONTROL stayed green.
- client: `lookupTargetDefs?.get(meta.target)` replaced by `undefined`:
3 failed (nameField, same-title, zh-CN); CONTROL green.
- picker: `targetDef` replaced by `undefined`: 2 failed (options, chip);
CONTROL green.
- empty label: `t('grid.empty')` replaced by `'(empty)'`: 6 failed
(every heading list that includes the empty group); the picker file
green.
</details>
<details><summary>Local runs at head 2e944be</summary>
- Targeted: 8 files, 162 tests passed.
- `@object-ui/core`, `@object-ui/plugin-grid`, `@object-ui/components`
whole packages (`pnpm --dir ui exec vitest run packages/core/
packages/plugin-grid/ packages/components/`): Test Files 1017 passed, 1
skipped; Tests 11601 passed, 51 skipped; lock VERDICT command-exit 0.
- `type-check` for the same three packages: exit 0.
- `pnpm --dir ui exec vitest run scripts/`: 171 files passed, 2 skipped;
exit 0.
- `dispatch-gates --commands` derived 38 families; all 38 run with exit
0; `--ran` reconciliation: 38 accounted, 0 NOT-MEASURED (derived zero).
- `ui` `check:new-line-citations`: 0 new citations. `overlap-check`:
clean against origin/main b1eb500, 0 PR heads.
- Not run locally, declared to CI: `test:repo`, the lint farm, `Lint
UI`, `Test UI` shards, dogfood (no `!`, no narrowing arm).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi)_
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbYRqkDAGuse5Wqbohi -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(ui): grouping headers and the filter value picker name a lookup by its target's `nameField`, and the empty group is translated
8
+
9
+
Clause-②: yes (widening)
10
+
Metadata-protocol: none
11
+
12
+
A lookup with no `displayField` is now named by the target object's declared `nameField`, the default the spec states for `displayField` ("the referenced object's name/title"). This is the same title the lookup's grid cell and the record header already show. Before, three places guessed a `name`, `label` or `title` key, and showed the raw record id when the target had none, for example a target titled by an autonumber such as `DEAL-2026-0001`:
13
+
14
+
-**Group headers of a list grouped by the lookup**, both server-grouped and client-grouped.
15
+
-**Filter builder value picker options** for the lookup, and the chip of the chosen value.
16
+
17
+
An explicit `displayField` on the lookup still wins. Grouping and filtering stay keyed by record id, so two records with the same title stay separate groups and separate options. The picker reads the target object's definition once per picker. The ObjectStack adapter serves later reads of it from its metadata cache.
18
+
19
+
The group of rows with no value now reads the grid's own empty-value string (`grid.empty`, for example "Empty" in English and "空" in Chinese) instead of the untranslated `(empty)`. It keeps its place in the group order: first when ascending and last when descending.
20
+
21
+
`@object-ui/core` adds `referencedRecordTitle(targetDef, record, displayField?)` to its public entry, a new export. It gives the title of a referenced record using the lookup's `displayField`, then the record-title ladder of `getRecordDisplayName`, and returns `undefined` instead of the `Record #<id>` floor.
0 commit comments