Repository navigation
fix(fields): an untyped repeater edits its stored rows as JSON in the record form - #29269
Merged
Merged
Conversation
…grid Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jQsK1ggWoa95TqasGU
…t dialog Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jQsK1ggWoa95TqasGU
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jQsK1ggWoa95TqasGU
Contributor
Author
|
domain:ui#3 · zhuangjianguo · session_01QsR2jV4dWohojjbTJTQq5m 席位核对 · ACCEPT · 2026-11-02T11:09ZHead-sha:
|
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.
Requested by Steedos · project thread
Fixes #29177
Clause-②: no
Metadata-protocol: none
维护者速读
repeater字段(无类型 JSON 数组)在记录编辑表单里改用 JSON 编辑器显示和编辑,与旁边的composite、record一致;原来走的是明细行网格,没有列,只画出编号行。[{label:'one',qty:1},…]在表单里看不到、也改不了。另一条路(按行的键推导列)实测会把qty存成字符串"5"、把嵌套对象显示为[object Object],会丢数据,所以没选。ui/packages/fields/src/field-type-alias.ts(repeater那一行),ui/packages/plugin-form/src/ModalForm.untypedRepeater.test.tsx,ui/packages/app-shell/src/views/studio-design/ObjectFormDesigner.test.tsx(宽度用例改指向)。cd ui && pnpm exec vitest run packages/plugin-form/src/ModalForm.untypedRepeater.test.tsx,预期 4 个用例全绿;或在 showcase 的 Field Zoo「Specimen — Full」点 Edit,看到 "Repeater (embedded array)" 显示两行 JSON。What changes
@objectstack/specdeclaresrepeateran untyped array of embedded JSON objects:FieldSchemahas no sub-field or column member, the strict field schema refusescolumnson it by name, and thefield/embedded-sub-fieldslint reports one. The form's alias table (mapFieldTypeToFormTypeinui/packages/fields/src/field-type-alias.ts) still sent it to the line-items grid (field:grid).GridFielddraws only declared columns (allColumns = cfg.columns || []), so a stored repeater showed numbered rows with Duplicate and Remove and no cell, and Add line appended an empty object.The one table row changes:
repeater: 'field:grid'becomesrepeater: 'field:object', the JSON editor (ObjectField) thatcomposite,recordandjsonalready use. The edit form now shows the stored array as pretty-printed JSON, an edit saves an array of objects (never a string), and unparsable text is refused before the save.GridField.tsxis not touched.Why the JSON editor and not derived columns. The card offered both, and both were measured. Driving
GridFieldwith columns derived from the row keys (the shape a derived-columns fix would hand it) on rows{label:'one',qty:1,meta:{color:'red'}}and{label:'two',qty:2,extra:true}: themetacell read[object Object], theextracell read the texttrue, and changing theqtycell to 5 emittedqty: "5", a string. A derived grid therefore loses edits (type drift on every touched cell) or has to be read-only, and either way cannot show nested values. The JSON editor round-trips any value the spec allows, and it is the face the other two untyped containers already have, so the three behave alike.What else moves, by consequence.
field:gridis in the form'sWIDE_FIELD_TYPES,field:objectis not. A repeater is now laid out at normal width in the record form and on the Studio form canvas, likecomposite. The canvas resolves width through the same alias table, so the two still agree.ObjectFormDesigner.test.tsxcase "spans a repeater field full-row" pinned the old width; it is repointed to assert the canvas matches the runtime resolution (field:object, not full-row). The seat accepted this file before it was edited.repeaterstays excluded (objectandgridare both inINLINE_EXCLUDED_FIELD_TYPES);FieldEditWidget.test.ts"the structured/computed spec spellings are closed corruption paths" is green unchanged.RepeaterCellRenderer, the row count) do not read the form alias.autoLayout.wideSpelling.test.tsthat described the repeater/grid width asymmetry as open is updated; that asymmetry no longer exists.Repeaters that declare columns. None exist to lose their grid:
git grepfortype: 'repeater'across the repo (examples, showcase, apps, tests, docs) andobjectstack-ai/hotcrmfound no object field that declarescolumns. The only hit carryingcolumnsis the lint test that proves such a field is refused. The metadata-formrepeaterrows inpackages/spec/src/**/*.form.tsare a different surface (Studio'sSchemaFormRepeaterField), which does not read this alias table.Tests
ui/packages/plugin-form/src/ModalForm.untypedRepeater.test.tsx, driven through the record Edit dialog (ModalForm, real registered widgets, a click on the real Update button), with the card's value[{label:'one',qty:1},{label:'two',qty:2}]and no columns:f_repeateras an array of objects with numericqty, never a string;qty: 4).ObjectFormDesigner.test.tsx: the repeater width case is repointed as above.Acceptance notes
repeater: 'field:grid'throughscripts/ablation-replace.mjs(anchor 1 -> 0) turned cases 1-3 red; the control stayed green. Restored: blob == HEAD,git diff HEADempty.objectstack dev --seed-admin --fresh) plus the Console Vite dev server on source, "Specimen — Full", Edit. With the alias row reverted: a full-width grid with header "#", rows 1 and 2 with Duplicate and Remove, a ghost row 3, Add line, no cell content. With this change: the field shows the two rows as JSON beside the composite and record editors; replacing the text with[{"label":"one","qty":5},{"label":"three","qty":3}]and clicking Update stored exactly that array of objects (read back throughGET /api/v1/data/showcase_field_zoo/ID). Screenshots are kept with the card thread.repeater/compositecannot declare typed sub-fields, so they are untyped JSON in forms and flows #25681.Verification
Gate and suite readings at head
92297c74; main74a19dd8was then merged (head7393c5a0). The merged commits touchui/packages/plugin-formsection fields andpackages/specrecord-page schemas, nothing this diff reads, and the scoped files below were re-run on7393c5a0.fields suite: 293 files green
cd ui && pnpm exec vitest run --maxWorkers=2 FILES, underos-verify-lock, in three parts ofpackages/fields' 293 test files: 95 passed 1 skipped (1729 tests), 102 passed (1750 tests), 95 passed (920 tests); each VERDICT command-exit 0.consumers and final-head re-run
ModalForm.jsonField-11448, the designer, autoLayout and inline-edit coverage tests,form-field-widget-namespace, the data-list, detail andwidget-dom-leak-sweepfiles that type a fieldrepeater: 15 files, 500 tests passed.7393c5a0after the merge: 10 files, 278 tests passed.type-check and lint
pnpm exec turbo run type-check --concurrency=2 --filter=@object-ui/fields --filter=@object-ui/plugin-form --filter=@object-ui/plugin-detail: Tasks 50 successful, 50 total (each runstsc -p tsconfig.test.jsontoo).pnpm exec eslinton the four touched source/test files: exit 0, 0 errors (6no-explicit-anywarnings on test casts, the sibling JSON-field test's shape).pnpm check:new-line-citations(fromui/): 0 new citations.derived gates: 34 of 34 exit 0
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackderived 34 commands (the same list on the merged head); each ran and exited 0, includingnode scripts/check-sdui-manifest.mjs, the changeset gates,pnpm check:type-check-debt(0 raw tsc errors above ledger) andpnpm --dir ui exec vitest run scripts/(168 files passed;check-hand-rolled-comment-mask.test.tstimed out once at 15 s beside a locked run and passed alone, 22 of 22).--ranreconciliation: 34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN.Generated by Claude Code