fix(plugin-detail): reference fields show [object Object] in inline edit#2024
Merged
Conversation
…ne edit
When toggling "编辑字段" in the record detail drawer, reference fields
(lookup / master_detail / tree / user / owner, or any field with
reference_to) fell through to a generic <input value={String(value)}>.
Server returns these values $expand-ed as record objects ({_id, name}),
so they rendered the literal "[object Object]".
Route reference fields to the real LookupField/UserField picker, feeding
the id extracted from the (possibly expanded) value; coerce any stray
object in the generic-input fallback via coerceToSafeValue. Thread
dataSource through DetailView -> SectionGroup -> DetailSection so the
picker can resolve related-record names while editing.
Adds DetailSection.inlineEdit.test.tsx regression coverage.
|
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.
问题
点开右侧记录详情抽屉 → 点编辑字段进入行内编辑后,引用类字段(如所属项目、制作工厂)的值显示成了字面量
[object Object]。原因
行内编辑模式(
DetailSection.tsx)不复用表单的字段控件注册表,而是手写各类型编辑器,且只特判了select/boolean/date/number。其余类型落到通用<input value={String(value)}>。引用字段的值由服务器
$expand成嵌套记录对象{_id, name, ...},String({...})即渲染成[object Object]。(只读模式用的是另一套能识别对象的渲染器,所以不受影响。)改动
lookup/master_detail/tree/user/owner,或任意带reference_to的字段)改走真正的LookupField/UserField选择器,通过新增的extractLookupId从(可能已展开的)值里取出 id 喂给控件;通用<input>兜底用coerceToSafeValue转换,杜绝[object Object]再泄漏。dataSource透传下去,使选择器在编辑时能解析/显示关联记录名。验证
@object-ui/plugin-detail类型检查通过