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

Commit b89583b

Browse files
os-zhuangclaude
andauthored
fix(fields): render the shared EmptyValue for an unparsable date (objectui#8581) (#8808)
`DateCellRenderer` handed every value to `formatDate`, whose own `'—'` for an invalid instant was wrapped in a `tabular-nums` span — naked punctuation with no `data-slot` of `empty-value` and no accessible name. `DateTimeCellRenderer`, one function down, has answered the identical input with the shared affordance all along; the guard is now spelled exactly as its sibling's. The intercept is at the renderer, not in `formatDate`: that formatter is shared with nine other call sites, all string consumers, and two landed pins assert its dash directly. A parseable value is untouched — same face, same overdue colour, same ISO `title`; a numeric epoch still renders. `cellRenderers.objectLiteral-8596.test.tsx` recorded this renderer's `{}` face as a dash that is NOT the affordance and said a fix here would have to move a pin rather than pass silently. It did; that pin moved with this change. Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH Co-authored-by: os-zhuang <noreply@anthropic.com>
1 parent 8033ad1 commit b89583b

4 files changed

Lines changed: 365 additions & 18 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
'@object-ui/fields': patch
3+
---
4+
5+
`DateCellRenderer`: an unparsable date value renders the shared `EmptyValue`
6+
affordance instead of `formatDate`'s hand-rolled em-dash (objectui#8581).
7+
8+
A `date` column holding `not-a-date` used to reach `formatDate`, which returns
9+
its own `'—'` for any value whose `new Date(...)` is invalid, and the renderer
10+
wrapped that string in a span classed `tabular-nums`. The result was naked
11+
punctuation: no `data-slot` of `empty-value`, no accessible name — the same
12+
defect class as objectui#8475 (`RelatedList`) and objectui#8491 (`ObjectGrid`).
13+
objectui#8490 routed this renderer's coerced-EMPTY input (`[]`, `''`,
14+
whitespace) to the shared affordance and left this input for its own card.
15+
16+
The guard is now spelled exactly as `DateTimeCellRenderer`'s one function down
17+
— the nearest sibling, which answers the identical input and has returned
18+
`EmptyValue` all along. The two date renderers no longer disagree about the
19+
same value, and that agreement is measured in the pin, not asserted.
20+
21+
**Visible change.** An unparsable value now reads "No value" to a screen reader
22+
and is muted like every other empty cell. The raw string that was reachable on
23+
hover through that span's `title` is gone on this branch only — nothing in the
24+
tree read it (searched with lit controls before the change). A PARSEABLE value
25+
is untouched: it keeps its formatted face, its overdue colour and its ISO
26+
`title`. A numeric epoch timestamp still renders — the guard reproduces
27+
`formatDate`'s own parse, so it is co-extensive with the dash it replaces and
28+
never wider.

‎packages/fields/src/__tests__/cellRenderers.objectLiteral-8596.test.tsx‎

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636
* - `location` / `geolocation` (and `json` / `object` / `composite` /
3737
* `record`) print the `{}` literal behind objectui#8481's DECLARED
3838
* json-literal fence. Left alone deliberately; pinned unchanged.
39-
* - `date` still draws `formatDate`'s hand-rolled em-dash with no accessible
40-
* name — objectui#8581's subject, the same renderer. This change does not
41-
* touch it, and `THE CENSUS` pins that it did not: the row is recorded as
42-
* a dash that is NOT the affordance, so a fix landing on it here would
43-
* have to move a pin rather than pass silently.
39+
* - `date` drew `formatDate`'s hand-rolled em-dash with no accessible name
40+
* — objectui#8581's subject, the same renderer. This change did not touch
41+
* it, and `THE CENSUS` pinned that it did not: the row was recorded as a
42+
* dash that is NOT the affordance, so a fix landing on it here would have
43+
* to move a pin rather than pass silently. It did: objectui#8581 landed,
44+
* `DateCellRenderer` now answers every unparsable value with the shared
45+
* affordance, and this file's two `date` assertions moved with it — the
46+
* census row to `true`, and THE BOUNDARY to the fix's own record.
4447
*
4548
* ── The direction is not open per family: `valueSchemaFor`'s arm decides ──
4649
* Read from `@objectstack/spec` `src/data/field-value.zod.ts` (v17.3.0), per
@@ -185,8 +188,15 @@ const REGISTERED_TYPE_COUNT = 53;
185188
* `'[Object]'` below must print. `affordance` records whether the cell draws
186189
* the shared "No value" glyph.
187190
*
188-
* ⚠️ `date` is recorded as `'—'` WITHOUT the affordance on purpose: that dash
189-
* is `formatDate`'s own, and it is objectui#8581's subject, not this card's.
191+
* ⚠️ `date` was recorded as `'—'` WITHOUT the affordance while
192+
* objectui#8581 was open: that dash was `formatDate`'s own and belonged to
193+
* that card's renderer, not this one's. objectui#8581 has since landed —
194+
* `DateCellRenderer` now intercepts every value it cannot parse (`{}` coerces
195+
* to `[Object]`, which `new Date` rejects) and returns the shared affordance,
196+
* so the row reads `true` here. Exactly as this file predicted: the fix had to
197+
* MOVE this pin rather than pass silently. The `date` census row and THE
198+
* BOUNDARY below are now this file's record of the other card's landing, and
199+
* the reason for the `{}` face itself is unchanged — `[Object]` is not a date.
190200
*/
191201
const OBJECT_LITERAL_CENSUS: ReadonlyArray<readonly [type: string, text: string, hasAffordance: boolean]> = [
192202
// ── the twenty that already coerced correctly — LOAD-BEARING ────────────
@@ -246,8 +256,8 @@ const OBJECT_LITERAL_CENSUS: ReadonlyArray<readonly [type: string, text: string,
246256
['secret', '••••••', false],
247257
['vector', '[Vector]', false],
248258
['grid', '[Grid]', false],
249-
// ── objectui#8581's hand-rolled dash — NOT the affordance, NOT moved here ─
250-
['date', '—', false],
259+
// ── objectui#8581 LANDED: the hand-rolled dash became the affordance ──
260+
['date', '—', true],
251261
];
252262

253263
/** A real value per type — the POPULATED half, which refuses the caricature. */
@@ -682,13 +692,24 @@ describe('objectui#8596 — an object literal is not a cell value, and these ren
682692
).toBe('tel:13800138000');
683693
});
684694

685-
it('THE BOUNDARY — `date` still draws its own dash: objectui#8581 keeps its subject', () => {
695+
it('THE BOUNDARY — `date` now draws the shared affordance: objectui#8581 landed on its own subject', () => {
696+
// This assertion is INVERTED from what it was while objectui#8581 was
697+
// open, and the inversion is the point: this file predicted that a fix
698+
// there would have to move a pin here rather than pass silently, and it
699+
// did. `{}` coerces to `[Object]`, which `new Date` rejects, so the
700+
// `date` cell takes objectui#8581's unparsable branch — the same
701+
// affordance `datetime` has always drawn for the same input. The reason
702+
// `{}` is not a date is unchanged; only who draws the answer moved.
686703
const { container } = renderCell('date', {});
687-
expect(textOf(container), 'date: the hand-rolled dash is unchanged here').toBe('—');
704+
expect(textOf(container), 'date: the glyph is still an em-dash').toBe('—');
688705
expect(
689706
affordance(container),
690-
'date: still NOT the shared affordance — objectui#8581 rules that renderer',
691-
).toBeNull();
707+
'date: the dash is now the shared affordance, not `formatDate`\'s bare one (objectui#8581)',
708+
).not.toBeNull();
709+
expect(
710+
affordance(container)?.getAttribute('aria-label'),
711+
'date: and it carries its accessible name',
712+
).toBe('No value');
692713
});
693714

694715
it("THE BOUNDARY — objectui#8481's json-literal fence is not reopened", () => {

0 commit comments

Comments
 (0)