Repository navigation
fix(fields): render the shared EmptyValue for an unparsable date (objectui#8581) - #8808
Conversation
…ectui#8581)
`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.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
✅ Console Performance Budget
The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it. 📦 Bundle Size Report
Size Limits
|
PM 复核 — 通过。CI 余 3 个 shard 在跑,绿后即武装 auto-merge。⭐⭐ 标杆项:你在自己的仪器上抓到一个假零
这是本班次要带走的第一条工具学。 一次空搜索和一次「确认不存在」在终端上长得一模一样,而前者会让你把「无消费者」当成已证事实去删一个属性。你在下结论之前发现了,并且把废掉的那次搜索报出来而不是抹掉。 ⭐ 第二条:一个不按预测方向失败的 ablation,被正确处理leg 1 预测「变红」,实得 ⛔ 更重要的是:四个 ⭐ 第三条:代价被测窄了,比卡假设的小卡假设 arm 1 会拿掉那个
⭐ 第四条:九个调用点被逐个列出,而不是被断言「修复属于渲染器而非 并且守卫与它替换的破折号是共延的: 关于那条被移动的姐妹 pin
席位意见 —— 你在
|
Fixes #8581
What changed
DateCellRenderer(packages/fields/src/index.tsx) now returns the sharedEmptyValuefor any value it cannot parse, instead of handing it toformatDateand wrapping that formatter's own em-dash in atabular-numsSPAN. Adatecolumn holdingnot-a-dateused to paint naked punctuation: nodata-slotofempty-value, no accessible name — the objectui#8475 / objectui#8491 class of defect. objectui#8490 routed this renderer's coerced-EMPTY input ([],'', whitespace) to the shared affordance and left this input, the other one reaching the same dash, to this card.The guard is spelled exactly as
DateTimeCellRenderer's, one function down in the same barrel —arm 1, on nearest-sibling parity, per the seat's ruling on the card. Arm 2 (printString(safe), as the number/percent family does on its NaN branch) is recorded in the test's header as a real argument that lost on precedent, not as a mistake.Three files: the renderer, a new pin, and one sibling pin that this change was required to move (below).
Zone 2 — both assumptions measured before implementing
前提: the
titlehint on that SPAN has no consumer — HOLDS. Searched forByTitlequeries,[title=...]selectors,getAttribute('title')reads, snapshot files, e2e specs and export paths. Zero read thistitle;isoStringoccurs only at its assignment and its one use. Lit controls on the same command shapes:getAttribute('title')returns 33 hits elsewhere in the tree andgetAttribute('data-slot')returns 10, so the zero is a reading. One earlier search shape (git grep -- 'packages/*/src') returned a false zero because wildcards do not prefix-match in a git pathspec; it was re-run against literal directories with a control before anything was concluded from it.Note the cost is narrower than the card assumed: arm 1 removes the SPAN only on the invalid branch, so a parseable value keeps its ISO
titleuntouched. That half is pinned.Assumption: the fix belongs at the renderer, not in
formatDate— HOLDS. Enumerated, as the card required: the sharedformatDatefrom@object-ui/corehas nine other call sites, and every one is a string consumer with noEmptyValueto return —plugin-gridObjectGrid.tsx:4416(date column)tabular-numsspanplugin-gridObjectGrid.tsx:4639(mobile card,'short')plugin-ganttObjectGantt.tsx:920/:927(tooltip / bar label)fieldswidgets/DateField.tsx:35(read-mode field)EmptyValuefor empty, not for unparsable)fieldswidgets/FormulaField.tsx:40fieldswidgets/GridField.tsx:375fieldswidgets/lookupColumnDisplay.tsx:239($datewrapper)coreutils/dataset-format.ts:192(measure)undefined— it pre-checks withDate.parseand never reaches the dashcomponentsrenderers/complex/data-table.tsx:789Two landed pins also assert that return string directly:
core'sdate-display.optionsStyle-7745.test.ts:183(formatDate('not a date', …)is'—') and this package'sdate-formatter-residue-4272.test.ts:118(thedatetimetwin). Moving the dash at its source would change eight faces and break two pins to fix one cell, so the renderer intercept is the honest repair. It is also co-extensive with the dash it replaces:formatDatereceivessafe,coerceToSafeValuenever returns aDate, sonew Date(safe)reproduces the formatter's own parse exactly — never wider.Zone 3 — the pin, and the live control
packages/fields/src/__tests__/dateCell.unparsableValue-8581.test.tsxpins the rendered DOM, not the formatter's return string:span.tabular-nums, no em-dash outside[data-slot="empty-value"], and the affordance present with its accessible name (aria-label="No value"). Plus: the raw value no longer survives as a hover hint, and a due-like unparsable value is not painted red.DateTimeCellRendereris driven through the samerenderCellcommand shape on the same fixtures, so "the two siblings now agree" is measured.THE AGREEMENTcompares the two cells' rendered markup directly. A populateddatetimerow is the liveness half: a harness that rendered nothing would pass every absence assertion in the file and fail that one.title; a pastdue_dateis still "Overdue Nd" in red; a numeric epoch timestamp still renders (a guard written onString(safe)would blank it, sincenew Date('1700000000000')is invalid whilenew Date(1700000000000)is not); aDateinstance still renders; objectui#8490's coerced-empty routing is unchanged.One sibling pin moved, by its own instruction
cellRenderers.objectLiteral-8596.test.tsxdeliberately recordeddateholding{}as a dash that is NOT the affordance, and stated that a fix landing on this renderer "would have to move a pin rather than pass silently". It did —{}coerces to[Object], whichnew Daterejects — so its census row and its BOUNDARY case were updated to record the landing. That is the only edit outside the renderer and the new pin, and it is exactly the behaviour that file asked for.Reverse verification (one-shot, restored)
Run from the committed fix, twice, each leg proving the mutation reached disk by blob hash before reading any result, each with a
trap … EXIT INT TERMrestore.Leg 1 — remove only the new guard (
git hash-object:11bff01c…→e86cfcc3…, guard occurrences 2 → 1,datetime's intact). Direction observed: not the predicted plain red — the tests failed withRangeError: Invalid time valuefrom the now-unconditionaltitle={date.toISOString()}. Reported as observed; because it is a crash rather than the real pre-fix tree, a second leg was run.Leg 2 — the genuine pre-fix renderer,
packages/fields/src/index.tsxat the merge base0e3bca45d(blobfebc56d9…verified on disk). 7 failed | 10 passed (17). The DEFECT rows fail on the intended first sentence —(The received element is written in words —
SPAN.tabular-nums— because tag-shaped fragments are eaten from GitHub bodies, backticks included.)— and the
titlerow fails asexpected [ 'not-a-date' ] to not include 'not-a-date', direct evidence the unfixed tree really did smuggle the raw value into a hover hint. All fourdatetimeLIVE CONTROL rows and every POPULATED / BOUNDARY row stayed GREEN under both legs: the control is a control, and the harness renders. The only LIVE CONTROL failure isTHE AGREEMENT, which is the sibling disagreement itself.Restored both times with
git checkout HEAD -- PATH(never bare), verified bygit diff HEADempty and worktree blob11bff01c…equal to the HEAD blob. No ablation artefact remains.Verification
All heavy runs through the shared verify lock; verdicts read from the lock's own
VERDICT command-exitline.pnpm exec vitest run packages/fields/(final tree)VERDICT command-exit 0pnpm --filter @object-ui/fields type-check(tsc --noEmit+tsconfig.test.json)plugin-detail×2,plugin-grid×2,coredate-display + dataset-formatnode scripts/check-changeset-presence.mjsnode scripts/check-governed-queue-guard.mjs --test THREE-PATHSAGENTS.mdfired ⛔ GOVERNED (exit 3), so the reading holdspnpm exec eslint . --no-inline-config --format jsonThe first
type-checkrun reportedCannot find module '@object-ui/*'— NOT MEASURED, not red: the dependency closure was unbuilt. Re-run afterpnpm --workspace-concurrency=2 --filter '@object-ui/fields^...' build, it is exit 0.CI is the authority on the full farm; this report is written at PR-open time and does not wait for it.
维护者速读(草稿)
改了什么。
date列遇到无法解析的值(例如not-a-date)时,不再画formatDate自己那个光秃秃的破折号,而是渲染共享的EmptyValue(读屏软件读作 "No value")。写法与一函数之下的DateTimeCellRenderer逐字一致 —— 那个姐妹渲染器一直就是这么答同一个输入的。为什么改。 无名可读的裸标点是缺陷,objectui#8475、objectui#8491 已经就这一类定过性;objectui#8490 修掉了同一渲染器的「空数组」入口,故意把这一个入口留给本卡。同一数据族的两个渲染器对同一输入各说各话,是这个仓反复付账的形状。
风险与代价(含回滚)。 代价只有一处、已实测:无法解析时,原先挂在 span
title上、鼠标悬停可见的原始字符串没有了 —— 全仓无任何读者(带对照的搜索)。能解析的值一律不受影响:同样的显示面、同样的逾期红色、同样的 ISOtitle,数字时间戳照常渲染。风险面只有@object-ui/fields一个包一个函数;回滚就是 revert 本 PR,无数据迁移、无契约变更。共享格式化函数formatDate没动(它还有九个调用点),这是刻意的。席位意见。 (留空,待席位定稿)
你要做的。 确认「无法解析 = 无值」这个口径可接受 —— 另一条路(arm 2:把原始文本照原样打出来)已在测试文件头部留档,它的理由是「记录里确实存了东西,说 No value 并不诚实」。若倾向那条路,本 PR 的测试结构可直接改判,不必推倒。
🤖 Generated with Claude Code
https://claude.ai/code/session_01611D6ZaRaMmwTNQmSbk8MH
Generated by Claude Code