Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 3261e64

Browse files
fix(core,components): one titleFormat interpolator for the record title (#10447, #10446) (#10555)
Fixes #10447 Fixes #10446 Clause-②: no — one renderer's private interpolation rebinds to the existing core authority, and core's empty test aligns with `recordDisplayValueAt`. No export, schema or accept set moves. Folded pair, one branch, executed from the triage on each card (comments 5827587063 and 5827564760) and the PM claims 5828659772 / 5828664602. objectui#10446's core fix lands first, then the H1 rebinds, so no commit on this branch renders `HT-2026-003 -` in the H1. ## Commits 1. `4c140cb9c` — objectui#10446, `@object-ui/core`. `formatTitleTemplate` judges each placeholder through the value half of `recordDisplayValueAt`, now the module-private `displayValueOf`: trim, then empty, with an expanded reference reduced to its display name. It used to test the raw value against null, undefined and the empty string on its own, so a whitespace-only value counted as resolved and the final whitespace collapse left its separator dangling. One implementation of the emptiness rule instead of two spellings of it. Exported signatures unchanged. 2. `ef988ac2f` — objectui#10447, `@object-ui/components`. The record page H1's `titleFormat` rung hands the declared template (string or Expression envelope) to core's `formatTitleTemplate` and takes its answer, including core's empty "nothing resolved"; the rung's separate unresolved-token test is gone. `cleanupTitleSeparators` had no other caller and is deleted with its test file. The rungs' order (objectui#9436) does not move. 3. `47536ebd8` — a typing fix inside the same helper: the declaration build refused a copy that re-widened to possibly-undefined (TS18048). 4. `b06b17020` — prose only: two pending changesets reconciled with the rung's one interpolator (see "Reconciled pending changesets" below), and this change's changeset names both. ## Measured before the change: the two interpolators, token by token Probe at base `6881e9e47`: the real `page:header` H1 and the header's own rung (its `interpolate` plus `cleanupTitleSeparators`, plus its "contains a brace, so decline" test) against core's `formatTitleTemplate`, same record. "declines" means the rung handed over to the unified resolver, which renders core's way. | Token rule | header rung | core | H1 before | H1 after | |---|---|---|---|---| | `{account} - {deal_no}`, `account` expanded to Acme | `Q3-042` | `Acme - Q3-042` | `Q3-042` | `Acme - Q3-042` | | `{a} - {b}`, `b` whitespace-only | `A` | `A -` | `A` | `A` | | `{a}, {b}`, `b` missing | `A,` | `A` | `A,` | `A` | | `Session — {a}`, `a` missing | `Session` | empty | `Session` | next rung | | `Static title` (no placeholder) | `Static title` | empty | `Static title` | next rung | | `{status}`, select `in_progress` | `In Progress` | `in_progress` | `In Progress` | `In Progress` (kept) | | `{{a}} - {{b}}` | declines | `A - B` | `A - B` | `A - B` | | `{ a } - { b }` | declines | `A - B` | `A - B` | `A - B` | | `{first-name} {a}` | declines | `Ada L` | `Ada L` | `Ada L` | | value containing a brace | declines | the value | the value | the value | | controls: dotted path, lookup with no display name, array, null, empty string, `0`, Expression envelope, the separators `·` `:` `–`, a 3-part template with its middle empty | equal | equal | equal | equal | After the change every row where core answers non-empty has H1 equal to core (select rows: equal to core over the labelled record). Where core answers empty, the H1 walks on to the next rung, as `getRecordDisplayName` walks from its template rung. ## Select option labels (H2): kept, without touching `formatTitleTemplate`'s signature - The header routed a top-level select token through `fieldOptionLabel`; core has no such hook. - `withOptionLabels` builds a copy of the record whose select values read as their option labels, and the rung renders core over that copy. `optionLabelFor` is the one label lookup in the file, shared with `interpolate`, so the two readers cannot drift. - Like-for-like with the dedupe: only top-level scalars are mapped (null, undefined, expanded references and arrays stay as they are), and a mapped value is never empty because the label falls back to the raw value. So the same placeholders resolve on the copy as on the raw record, and `record:details`, which renders the template over the raw record, still decides about the field the H1 shows. Pinned in plugin-detail (the Status-row cases below). - In-repo census, with a lit control. Instrument: `git grep -n -E "titleFormat['\"]?\s*[:=]" -- ':!*.test.*' ':!**/__tests__/**' ':!**/CHANGELOG.md'`. The one object declaration it finds outside tests is `content/docs/guide/building-crud-app.md`'s `titleFormat: '{title}'`, a text field, so no in-repo `titleFormat` names a select field. Control: the same pattern over test files is non-empty and includes `page-header-title.test.tsx`'s `{status}` select case. First-party producers outside this repo (objectstack platform objects, e.g. `sys_audit_log` with `{action} · {object_name}` and `sys_member` with `{user_id} ({role})`) do name select fields, and each of those also declares a `nameField`, so their template rung is reached only when that pointer is blank on a record. Re-derive with `git grep -n titleFormat origin/main -- 'packages/**/src/**'` in objectstack. ## `interpolate`'s callers (H3) It keeps two callers, both `page:header`'s own templates: `title` and `subtitle`. They are unchanged. The `titleFormat` rung was the third and no longer comes through it, so `interpolate` stays. Instrument: `grep -n "interpolate(" packages/components/src/renderers/layout/containers.tsx`. ## Who the #10446 rule reaches (H4) - `formatTitleTemplate` is called by `getRecordDisplayName`'s template rung (core), `DetailView.resolveDisplayTitle` and the `record:details` H1 dedupe (plugin-detail), and now `page:header`. `@object-ui/app-shell` re-exports it as `formatRecordTitle`. - `getRecordDisplayName`, so every resolver-backed surface: app-shell `RecordDetailView`; components `page:header`; core `sort-values`; fields `index` and `LookupField`; plugin-calendar `ObjectCalendar`; plugin-detail `DetailView` and `RelatedList`; plugin-gantt `ObjectGantt`; plugin-kanban `ObjectKanban`; plugin-list `ObjectGallery`; plugin-map `ObjectMap`; plugin-tree `ObjectTree`. Instrument: `git grep -n "getRecordDisplayName(" -- 'packages/**/src/**' 'apps/**/src/**' ':!**/__tests__/**' ':!*.test.*'`. - The existing `record-title` suites stay green, and every other test file that mentions `titleFormat` was run too (Gates below). ## Pins, red on base then green on head New files: - `packages/core/src/utils/__tests__/record-title.whitespacePlaceholder-10446.test.ts` - `packages/components/src/__tests__/page-header-title.oneInterpolator-10447.test.tsx` - `packages/plugin-detail/src/renderers/__tests__/record-details.titleFormatOneInterpolator-10447.test.tsx` Red leg, from committed head `ef988ac2f`: both source files checked out at base `6881e9e47`, new tests kept. On-disk proof before the run: `displayValueOf` 0 hits and the old empty test 1 hit in `record-title.ts`; `withOptionLabels` 0 hits and `cleanupTitleSeparators` 2 hits in `containers.tsx`. Result `Tests 11 failed | 25 passed (36)`: - core: THE CARD `expected 'HT-2026-003 -' to be 'HT-2026-003'` at both doors; blank leading placeholder `expected '- Acme' to be 'Acme'`; agreement rows "spaces" `expected '- K' to be 'K'` and "no-break spaces". - `page:header`: THE CARD `expected 'Q3-042' to be 'Acme - Q3-042'`; whitespace `expected 'HT-2026-003' to be 'HT-2026-003 -'` (H1 against core); comma `expected 'Q3-042,' to be 'Q3-042'`; literal prefix `expected 'Session' not to be 'Session'`. - `page:header` beside `record:details`: THE CARD `expected 'Q3-042' to be 'Acme - Q3-042'`; #10446 in the page `expected 'HT-2026-003' to be 'HT-2026-003 -'`. - The 25 that stay green are the controls, including every select option-label case: the H1's label behaviour is kept, not changed. Restore leg: `git checkout HEAD --` both paths inside an EXIT/INT/TERM trap, blob hashes equal to `ef988ac2f`'s (`d7e714385`, `86a980376`), `git diff HEAD` empty. `47536ebd8` differs from `ef988ac2f` only by the typing fix inside `withOptionLabels`, a file the red leg replaces with base, so the red and green numbers carry over. Green leg: the three files pass on head inside the package runs listed under Gates; the two render files alone read `Tests 21 passed (21)`. ## Gates Code, type and test gates ran at `47536ebd8`; the changeset gates were re-run on the prose commit `b06b17020` (no code or test file moved between the two). - `pnpm --workspace-concurrency=2 --filter "@object-ui/plugin-detail^..." build` (the dependency closure, includes core and components): exit 0. - `type-check` of `@object-ui/core`, `@object-ui/components`, `@object-ui/plugin-detail`: `Done` ×3, exit 0. Each package's test program lists its new test file (`tsc -p tsconfig.test.json --listFiles`, 1 match per package). - `pnpm exec vitest run packages/core/`: `Test Files 172 passed (172)`, `Tests 3501 passed (3501)`. - `pnpm exec vitest run packages/components/ packages/plugin-detail/`: `Test Files 507 passed | 2 skipped (509)`, `Tests 4976 passed | 25 skipped (5001)`. - Every other test file that mentions `titleFormat` (app-shell, fields, plugin-dashboard, plugin-grid, plugin-map, react, types): `Test Files 21 passed (21)`, `Tests 218 passed (218)`. - `pnpm --filter @object-ui/components run test:dist`: `Test Files 2 passed (2)`. - `check-changeset-presence` (at `b06b17020`): `✅ 7 source file(s) of 3 released package(s) changed, and this change declares 1 changeset(s): .changeset/10447-one-title-interpolator.md.` - `check:new-line-citations` (at `b06b17020`): `VERDICT new-cross-file-line-citations: 0 new citation(s)`. - `check:control-bytes` (at `b06b17020`): `✅ check-control-bytes: OK`. - At `b06b17020`: `check-changeset-no-major` `✅ No changeset declares a major bump.`; `check-changeset-fixed` `✅ All workspace packages are in the changeset fixed group.`; `check:pending-changeset-literals` `✅ No test source names a pending changeset.`; `check-changeset-overwrite` exit 0, report-only, listing exactly the two reconciled entries (`2 modified, 0 deleted`); `check:changeset-claims` exit 0, report-only, and the entries it still lists name the touched files for other aspects (reviewed; none describes the `titleFormat` rung's interpolation). - `check:test-path-roots`, `check-vi-mock-override-shape`: exit 0. - eslint on the six touched source and test files: 0 errors (warnings are the repo-wide `no-explicit-any` / `only-export-components` level). The package-wide `pnpm lint` is CI's run; not measured here. ## Reconciled pending changesets Two changesets still pending in the same release described the rung as rendered by the header's own interpolation. Each is reconciled in the form objectui#10533 / #10540 used, with its frontmatter byte-identical (md5 of the frontmatter block equal before and after: `3d9e2a1e59bc11924bb99ffd9eea81e3` and `ce888ebde4729564f67bca69a7928743`): - `.changeset/9436-page-header-declared-pointer-order.md`: item 3 now reads "rendered at this change with the header's own interpolation", and "At this change, objects that declare a pointer and no `titleFormat`, and objects that declare a `titleFormat` and no pointer, render exactly as before". A dated note follows: "Dated note, 2026-09-25 — the record title's titleFormat rung now renders through core's formatTitleTemplate — objectui#10447". It states that option labels are still translated, via `withOptionLabels`, and that the order is unchanged. - `.changeset/9174-interpolate-fastpath-trim.md`: "At this change `page:header`'s `title`/`subtitle` (and the record-title `titleFormat`) all went through `interpolate()`". The same dated note follows, stating that `title` and `subtitle` still go through `interpolate()`, so that entry's fix holds for them unchanged. - `.changeset/10447-one-title-interpolator.md` names both entries. Every other pending `.changeset/*.md` was re-grepped for present-tense claims about the header's own `titleFormat` interpolation or `cleanupTitleSeparators`, and none has one. Instrument: `git grep -n -i -E "cleanupTitleSeparators|separator cleanup|interpolat|formatTitleTemplate|titleFormat" -- .changeset/`. The nearest hits are about `page:header`'s `title` (objectui#10117, #8923) or other readers, and still hold. ## File surface - `packages/core/src/utils/record-title.ts`, and beside it the new `packages/core/src/utils/__tests__/record-title.whitespacePlaceholder-10446.test.ts`. - `packages/components/src/renderers/layout/containers.tsx`, and beside it the new `page-header-title.oneInterpolator-10447.test.tsx`, a docblock-only edit to `page-header-title.test.tsx`, and the deleted `cleanup-title-separators.test.ts` (its function had no other caller). - `packages/plugin-detail/src/renderers/__tests__/record-details.titleFormatOneInterpolator-10447.test.tsx`: new, test-only, outside the claims' listed surface ("tests beside each"). It is where `page:header` and `record:details` render together (the objectui#9436 and objectui#10360 agreement files live beside it), which the H5 pin needs. No plugin-detail source changes. - `.changeset/10447-one-title-interpolator.md` (patch on `@object-ui/core` and `@object-ui/components`), plus the two reconciled entries above. ## Scope - objectui#10499 is not addressed here. The H1's row source is unchanged (`ctx.data`, the raw served row). This neither helps nor hinders that fix beyond one fact: the rung and `record:details`' dedupe now call the same function and differ only in the row they pass it. - objectui#10462 (action-entry `params`, same file) is untouched. ## Acceptance notes - Behaviour change on the rung, by the one-authority rule: a template none of whose placeholders resolves no longer shows its literal text in the H1 (`Session — {user_id}` with no user used to read `Session`); the H1 walks on to the next rung. - A resolved placeholder now emits the trimmed string `recordDisplayValueAt` returns. After core's whitespace collapse this is visible only where a padded value sits against a non-space literal, for example `({code})`. - `DetailView.resolveDisplayTitle` still renders the template over the raw record, so on the non-synthesized detail header a select token reads as its raw value where `page:header` shows the label. That predates this change and is read from source only, not measured through a running page. --- _Generated by [Claude Code](https://claude.ai/code/session_014mXUNuFomfj24w7s1pZzhN)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent fde4caf commit 3261e64

10 files changed

Lines changed: 683 additions & 136 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/core': patch
3+
'@object-ui/components': patch
4+
---
5+
6+
One `titleFormat` interpolator for the record title (objectui#10447, objectui#10446).
7+
8+
`@object-ui/core`: `formatTitleTemplate` now judges a placeholder empty the way `recordDisplayValueAt` does: trim, then empty. A whitespace-only value used to count as resolved, so `{contract_no} - {name}` with a blank `name` rendered `HT-2026-003 -` in `formatTitleTemplate` and in `getRecordDisplayName`'s `titleFormat` rung, and so on every surface backed by that resolver. It now renders `HT-2026-003`. Both functions run one shared implementation of the rule, so a resolved placeholder renders the same trimmed display string `recordDisplayValueAt` returns. The exported signatures are unchanged.
9+
10+
`@object-ui/components`: the record page H1 (`page:header`) renders its `titleFormat` rung through core's `formatTitleTemplate`, the function `getRecordDisplayName` and `record:details`' H1 dedupe already use, instead of its own interpolation and separator cleanup. Visible changes on that rung:
11+
12+
- An expanded lookup token renders its display name: `{account} - {deal_no}` reads `Acme - Q3-042` where the H1 used to drop the lookup and read `Q3-042`, so `record:details` no longer prints the row it wrongly treated as distinct from the heading.
13+
- A comma left by an empty placeholder is stripped: `{deal_no}, {code}` with no `code` reads `Q3-042`, not `Q3-042,`.
14+
- A template none of whose placeholders resolves no longer shows its literal text (`Session — {user_id}` with no user used to read `Session`); the H1 walks on to the next rung, as `getRecordDisplayName` does.
15+
- A select token still reads as its translated option label: the label is applied to a copy of the record before core renders it.
16+
17+
The rungs' order is unchanged. `page:header`'s own `title` and `subtitle` templates keep their existing interpolation.
18+
19+
This supersedes how two earlier changesets, still pending in the same release, describe the `titleFormat` rung; each now carries a dated note naming this card. objectui#9436 (the declared pointer outranks `titleFormat` in `page:header`) said the template kept the header's own interpolation. objectui#9174 (`interpolate()`'s no-token fast path) listed the record-title `titleFormat` among `interpolate()`'s callers. Both describe the header as it was at their change; from this release the rung renders through `formatTitleTemplate`.

‎.changeset/9174-interpolate-fastpath-trim.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Fix `interpolate()`'s no-token fast path skipping its own trim (objectui#9174).
66

7-
`page:header`'s `title`/`subtitle` (and the record-title `titleFormat`) all go through
7+
At this change `page:header`'s `title`/`subtitle` (and the record-title `titleFormat`) all went through
88
`interpolate()` in `packages/components/src/renderers/layout/containers.tsx`. When the
99
template contained a `{token}` the function collapsed and trimmed whitespace before
1010
returning; when it contained no `{` at all it returned the raw string untouched. A
@@ -15,6 +15,14 @@ its own heading to the authored header, already trimmed and correctly read "no t
1515
`PageRenderer` also drew its own implicit heading — two `<h1>` elements on one document,
1616
the broken outline objectui#3434 closed, arriving through a different door.
1717

18+
⚠️ **Dated note, 2026-09-25 — the record title's titleFormat rung now renders through core's formatTitleTemplate — objectui#10447.**
19+
Later in this same release the record-title `titleFormat` stopped going through
20+
`interpolate()`: it renders through `@object-ui/core`'s `formatTitleTemplate`, and a
21+
select token still reads as its translated option label, applied by
22+
`withOptionLabels` to a copy of the record before core renders it. `title` and
23+
`subtitle` still go through `interpolate()`, so the fix below holds for both of them
24+
unchanged.
25+
1826
The fix removes the divergence rather than patching around it: the no-`{` fast path
1927
still skips the token-substitution `replace()` callback (its actual performance
2028
saving), but every template — token or not — now falls through to the same, single

‎.changeset/9436-page-header-declared-pointer-order.md‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,25 @@ The header now resolves its title in this order:
2121
2. the declared pointer: `nameField`, then its deprecated `displayNameField`
2222
alias. This rung is new, and it only applies when the pointer holds a value
2323
on the record;
24-
3. `titleFormat`, rendered with the header's own interpolation, including
25-
i18n option labels, exactly as before;
24+
3. `titleFormat`, rendered at this change with the header's own
25+
interpolation, including i18n option labels, exactly as before;
2626
4. the type-aware derivation, then the record-key rung, then
2727
`${objectLabel} ${id}`, all unchanged.
2828

2929
A pointer that is blank on a record still falls through to the template.
30-
Objects that declare a pointer and no `titleFormat`, and objects that declare a
31-
`titleFormat` and no pointer, render exactly as before.
30+
At this change, objects that declare a pointer and no `titleFormat`, and
31+
objects that declare a `titleFormat` and no pointer, render exactly as before.
32+
33+
⚠️ **Dated note, 2026-09-25 — the record title's titleFormat rung now renders through core's formatTitleTemplate — objectui#10447.**
34+
Later in this same release rung 3 stopped using the header's own
35+
interpolation: the template goes to `@object-ui/core`'s `formatTitleTemplate`,
36+
the renderer `getRecordDisplayName`, `DetailView` and the `record:details` H1
37+
dedupe already use. A select token still reads as its translated option label,
38+
applied by `withOptionLabels` to a copy of the record before core renders it.
39+
The order above is unchanged. What the rung now renders differently for a
40+
`titleFormat`-only object (an expanded lookup token, a whitespace-only value,
41+
a template with no resolved placeholder) is stated in the objectui#10447 entry;
42+
the rest of this entry is kept as the reading of this change.
3243

3344
**Upgrade effect.** Any object that declares BOTH a `nameField` (or
3445
`displayNameField`) and a `titleFormat` whose rendering differs from that

‎packages/components/src/__tests__/cleanup-title-separators.test.ts‎

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* The record page H1's `titleFormat` rung renders through core's
11+
* `formatTitleTemplate` — ONE interpolator (objectui#10447).
12+
*
13+
* ## The defect
14+
*
15+
* `PageHeaderRenderer` rendered the legacy template with its own `interpolate`
16+
* plus a separator cleanup, while `getRecordDisplayName`'s template rung,
17+
* `DetailView.resolveDisplayTitle` and `record:details`' H1 dedupe all call
18+
* `formatTitleTemplate`. The two implementations had different token rules.
19+
* The card's case: an expanded lookup token rendered as NOTHING in the header
20+
* and as the reference's display name in core, so
21+
* `titleFormat: '{account} - {deal_no}'` read `Q3-042` in the H1 while the
22+
* dedupe compared `Acme - Q3-042`.
23+
*
24+
* ## What is pinned
25+
*
26+
* - THE CARD: the H1 is exactly the string core renders for the same record.
27+
* - The same equality across the other token shapes the two implementations
28+
* were measured to treat differently, plus the shapes they already agreed
29+
* on as controls. Each expectation is core's own output, read at run time,
30+
* so a change to core moves the H1 with it rather than reddening here.
31+
* - A template none of whose placeholders resolves is core's empty answer, so
32+
* the H1 walks on to the next rung instead of showing the template's
33+
* literal text.
34+
* - The option-label translation the H1 has always applied to a select token
35+
* is KEPT, applied to the record before core renders it. So the H1 equals
36+
* core over that labelled record, and deliberately differs from core over
37+
* the raw record by exactly the label.
38+
*
39+
* Every fixture declares no name pointer and gives the template's fields
40+
* types the type-aware derivation cannot take (or none at all), so the
41+
* template is the rung that answers.
42+
*/
43+
44+
import { describe, it, expect, afterEach } from 'vitest';
45+
import { render, cleanup } from '@testing-library/react';
46+
import { ComponentRegistry, formatTitleTemplate } from '@object-ui/core';
47+
import { ActionProvider, RecordContextProvider } from '@object-ui/react';
48+
// Registers `page:header` at module scope, NOT inside a `beforeAll` — there the
49+
// cold transform is billed to `hookTimeout`
50+
// (object-ui/no-dynamic-import-in-test-hook, objectui#3010). This keeps the
51+
// file in the light `dom` project instead of adding it to `heavyDomTests`.
52+
import '../renderers';
53+
54+
function PageHeader({ schema }: { schema: any }) {
55+
const Component = ComponentRegistry.get('page:header');
56+
if (!Component) throw new Error('page:header not registered');
57+
// eslint-disable-next-line react-hooks/static-components -- ComponentRegistry.get returns a registered component (stable), not one created during render
58+
return <Component schema={schema} />;
59+
}
60+
61+
/** Render the real `page:header` for one record and return its H1 text. */
62+
function h1Of(objectSchema: any, record: any): string | null | undefined {
63+
const { container } = render(
64+
<ActionProvider>
65+
<RecordContextProvider
66+
objectName={objectSchema.name}
67+
recordId={record.id}
68+
data={record}
69+
objectSchema={objectSchema}
70+
>
71+
<PageHeader schema={{ type: 'page:header' }} />
72+
</RecordContextProvider>
73+
</ActionProvider>,
74+
);
75+
return container.querySelector('h1')?.textContent;
76+
}
77+
78+
afterEach(() => {
79+
cleanup();
80+
});
81+
82+
/** Lookup-typed and number-typed fields: the derivation takes neither. */
83+
const dealFields = {
84+
account: { type: 'lookup', reference_to: 'account', label: 'Account' },
85+
deal_no: { type: 'autonumber', label: 'Deal No' },
86+
};
87+
88+
const deal = (titleFormat: unknown) => ({ name: 'deal', label: 'Deal', titleFormat, fields: dealFields });
89+
90+
describe('page:header H1 — the titleFormat rung renders what core renders (#10447)', () => {
91+
it('THE CARD — an expanded lookup token renders its display name, exactly as core does', () => {
92+
const titleFormat = '{account} - {deal_no}';
93+
const record = { id: 'rec-1', account: { id: 'a1', name: 'Acme' }, deal_no: 'Q3-042' };
94+
95+
const h1 = h1Of(deal(titleFormat), record);
96+
97+
expect(h1).toBe(formatTitleTemplate(titleFormat, record));
98+
expect(h1).toBe('Acme - Q3-042');
99+
});
100+
101+
// [name, template, record]. Every template names only fields the fixture
102+
// leaves untyped or types out of the derivation, and every record resolves
103+
// at least one placeholder, so core's answer is non-empty and IS the H1.
104+
const shapes: Array<[string, unknown, Record<string, unknown>]> = [
105+
['an expanded lookup with no display name drops with its separator', '{account} - {deal_no}', { account: { id: 'a1' }, deal_no: 'Q3-042' }],
106+
['a whitespace-only value drops with its separator (#10446)', '{contract_no} - {code}', { contract_no: 'HT-2026-003', code: ' ' }],
107+
['a comma left by an empty placeholder is stripped', '{deal_no}, {code}', { deal_no: 'Q3-042' }],
108+
['a double-brace token', '{{deal_no}} - {{code}}', { deal_no: 'Q3-042', code: 'X9' }],
109+
['a token with inner whitespace', '{ deal_no } - { code }', { deal_no: 'Q3-042', code: 'X9' }],
110+
['a hyphenated key', '{deal-code} {deal_no}', { 'deal-code': 'EU', deal_no: 'Q3-042' }],
111+
['the Expression envelope', { dialect: 'template', source: '{deal_no} - {code}' }, { deal_no: 'Q3-042', code: 'X9' }],
112+
['CONTROL — a dotted path into an expanded lookup', '{account.name} - {deal_no}', { account: { id: 'a1', name: 'Acme' }, deal_no: 'Q3-042' }],
113+
['CONTROL — a three-part template with its middle placeholder empty', '{deal_no} - {code} - {region}', { deal_no: 'Q3-042', region: 'EMEA' }],
114+
['CONTROL — a literal prefix beside a resolved placeholder', 'Deal {deal_no}', { deal_no: 'Q3-042' }],
115+
];
116+
117+
for (const [name, titleFormat, values] of shapes) {
118+
it(name, () => {
119+
const record = { id: 'rec-2', ...values };
120+
const expected = formatTitleTemplate(titleFormat as never, record);
121+
// Guard the fixture, not the renderer: an empty core answer would mean
122+
// the H1 came from another rung and the equality below proved nothing.
123+
expect(expected).not.toBe('');
124+
expect(h1Of(deal(titleFormat), record)).toBe(expected);
125+
});
126+
}
127+
128+
it('a template none of whose placeholders resolves declines, so its literal text is not the H1', () => {
129+
// Core's rule: no placeholder resolved ⇒ ''. The rung takes that answer
130+
// and the H1 walks on, here to the `${objectLabel} ${id}` floor, instead
131+
// of printing the template's literal prefix as if it were a title.
132+
const titleFormat = 'Session — {user_id}';
133+
const record = { id: 'rec-00000003' };
134+
expect(formatTitleTemplate(titleFormat, record)).toBe('');
135+
136+
const h1 = h1Of(deal(titleFormat), record);
137+
138+
expect(h1).not.toBe('Session');
139+
expect(h1).toBe('Deal rec-0000');
140+
});
141+
});
142+
143+
describe('page:header H1 — a select token keeps its option label, applied before core renders (#10447)', () => {
144+
const statusOptions = [
145+
{ value: 'in_progress', label: 'In Progress' },
146+
{ value: 'won', label: 'Won' },
147+
];
148+
const ticket = (fields: unknown) => ({
149+
name: 'ticket',
150+
label: 'Ticket',
151+
titleFormat: '{deal_no} · {status}',
152+
fields,
153+
});
154+
const recordFields = {
155+
deal_no: { type: 'autonumber', label: 'Deal No' },
156+
status: { type: 'select', label: 'Status', options: statusOptions },
157+
};
158+
159+
it('the H1 is core over the record with the select value read as its label', () => {
160+
const record = { id: 'rec-4', deal_no: 'Q3-042', status: 'in_progress' };
161+
162+
const h1 = h1Of(ticket(recordFields), record);
163+
164+
expect(h1).toBe(formatTitleTemplate('{deal_no} · {status}', { ...record, status: 'In Progress' }));
165+
expect(h1).toBe('Q3-042 · In Progress');
166+
// Where it deliberately differs from core over the RAW record: the label.
167+
expect(formatTitleTemplate('{deal_no} · {status}', record)).toBe('Q3-042 · in_progress');
168+
});
169+
170+
it('the array form of `fields` maps the same way', () => {
171+
const record = { id: 'rec-5', deal_no: 'Q3-042', status: 'won' };
172+
const arrayFields = Object.entries(recordFields).map(([name, def]) => ({ name, ...def }));
173+
174+
expect(h1Of(ticket(arrayFields), record)).toBe('Q3-042 · Won');
175+
});
176+
177+
it('a value no option declares renders raw', () => {
178+
const record = { id: 'rec-6', deal_no: 'Q3-042', status: 'archived' };
179+
180+
expect(h1Of(ticket(recordFields), record)).toBe('Q3-042 · archived');
181+
});
182+
183+
it('a blank select value is still empty, and drops with its separator', () => {
184+
const record = { id: 'rec-7', deal_no: 'Q3-042', status: ' ' };
185+
186+
expect(h1Of(ticket(recordFields), record)).toBe('Q3-042');
187+
});
188+
});

‎packages/components/src/__tests__/page-header-title.test.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,12 @@ describe('PageHeaderRenderer — record title resolution', () => {
131131
* `getRecordDisplayName` walks from a blank steps 1+2 to step 3;
132132
* - an object that declares no pointer still takes its title from the
133133
* template, ABOVE the type-aware derivation, which stays where it was;
134-
* - the template keeps THIS renderer's interpolation, which routes a select
135-
* value through its option label. Core's `formatTitleTemplate` renders the
136-
* raw value, so a ladder that consulted the whole unified resolver above
137-
* the template would change this H1 and not just the order;
134+
* - the template's select value still reads as its option label. Since
135+
* objectui#10447 the rung renders through core's `formatTitleTemplate`
136+
* over a record copy whose select values read as their labels; the
137+
* unified resolver renders the raw value, so a ladder that consulted the
138+
* whole resolver above the template would change this H1 and not just the
139+
* order;
138140
* - an explicit `schema.title` still outranks both.
139141
*/
140142
describe('PageHeaderRenderer — the declared pointer outranks `titleFormat` (#9436)', () => {

0 commit comments

Comments
 (0)