fix(fields): 内嵌子表 date 列回显存量 ISO 值 (#3566) - #3718
Draft
baozhoutao wants to merge 1 commit into
Draft
Conversation
GridField hand-rolls its own cell input rather than going through DateField, so objectui#3127's fix did not reach it: a `date` column whose value carries the API's ISO shape (`2026-06-17T00:00:00.000Z`) fed that string straight into `<input type="date">`, which accepts only `YYYY-MM-DD` and rejects everything else SILENTLY — the attribute lands in the DOM while `input.value` reads back `''`, so the cell painted its empty placeholder on a row that has a value. Reuse `toDateInputValue` from #3127 instead of adding a second date normaliser. It passes a leading `YYYY-MM-DD` through verbatim, so a date-only value is not re-parsed as UTC midnight and shifted a day earlier west of Greenwich. The write side is deliberately unpaired: `onChange` still emits the control's own plain `YYYY-MM-DD`, which is DateField's contract too, so read and write stay on one basis. Fixes #3566 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3566
#3127 的同族缺口,落在子表面上。
缺陷
GridField自己手搓单元格输入,不走DateField,所以 #3127 的修复够不着它。date列拿到 API 的 ISO 形状时,String(val)把它原样喂进<input type="date">:该控件只接受
YYYY-MM-DD,其余形状静默拒收 —— 属性照样落进 DOM,input.value读回空串,于是有值的行画出空占位。改法
复用 #3127 落地的
toDateInputValue,不新增第二个日期归一化 helper:它对开头是
YYYY-MM-DD的串原样透传,避免 date-only 被new Date()按 UTC 午夜解析后、再读本地日期分量而在格林威治以西整体差一天。写回侧刻意不配对:
onChange仍交出控件自己的 plainYYYY-MM-DD—— 与DateField同一约定,读写保持同一基准。验证
单测(先证伪):把修复行还原后,新测以本缺陷的精确症状失败 ——
恢复后
pnpm exec vitest run packages/fields/→ 64 files / 973 tests passed;连同消费方plugin-form/合跑 36 files / 380 tests passed。新增 4 条:ISO 与裸日期两种形状都渲染2026-06-17、空值保持空、写回仍是 plainYYYY-MM-DD。真机(framework showcase + 本分支 console dev,对象
showcase_expense_line的incurred_on,走inlineEdit: 'grid'的内嵌子表):attr.value2026-06-17T00:00:00.000Z""← 复现缺陷2026-06-172026/06/17✅2026-06-20保存 → 后端与 sqlite 原始行均为2026-06-20,相邻未触碰行仍是2026-06-18(未被重新提交或改坏)。范围
无 changeset(AGENTS.md §9:纯 bug 修复不写)。
同族但故意未修、已拆出 #3569:
deriveMasterDetail.ts把datetime/time折叠成date列,导致 datetime 子表字段的时间分量在写回时被静默丢弃;只读展示面(displayText()、只读表的String(...))同源。两者的修复都要先解开类型折叠并跨plugin-form,在此之前GridField无从分辨该显示「日」还是「日+时间」,按日渲染会把 datetime 的时间从展示里抹掉。本 PR 不会让 #3569 更差:datetime 列由「空白」变为「显示日历日」。🤖 Generated with Claude Code