Repository navigation
Commit a8aa6ab
feat(plugin-form): a multi file / image field takes the whole row in the form auto-layout (#34698)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBU5y97XtBcJ8qSLSR3B3Djd)_
Fixes #34668
repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:表单自动排版里,对象字段声明 `multiple: true` 的文件 /
图片字段默认占整行;弹窗、整页表单、分页签表单、向导表单走同一条规则。单文件 / 单图仍占一格。
- **为什么改**:3 列的新建弹窗里,多图 / 多附件字段原来只占一格(测得每行 `[2, 3, 3]`
个,即与普通字段同宽)。详情页早已按同一判据让多文件字段占整行,这次表单与它对齐(裁定 6939109581「只放宽多文件附件」)。
- **风险与回滚**:只改默认宽度,不加元数据键、不改导出;spec 里 `FormField.span`
的说明文字同步改为如实描述(只改文字,不改键和取值);作者写了 `span: 'full'` 或 `colSpan` 的照写的来(显式
`span: 'auto'` 不收窄,`colSpan: 1` 才保持一格)。回滚即还原 `autoLayout.ts` 一个提交。
- **先看**:`ui/packages/plugin-form/src/autoLayout.ts`(新增
`isWideFormField`,`resolveColSpan` 与 `twelfthsFor`
改为问它);`ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx`;`packages/spec/src/ui/view.zod.ts`
中 `FormField.span` 的一句说明。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx`,预期
17 passed。
- **需要你做的**:无,席位落地。
## What changes
- `ui/packages/plugin-form/src/autoLayout.ts`: a module-private
`isWideFormField(field)` answers the `span: 'auto'` default. It returns
true for a wide type (`isWideFieldType`, unchanged), and for a `file` /
`image` field (bare or `field:` spelling) whose **object field**
declares `multiple: true`. This is a parallel copy of plugin-detail's
`MULTI_FILE_FIELD_TYPES` / `isWideDetailField`, with a docblock that
points at it. plugin-form does not import from plugin-detail.
- `resolveColSpan` (the CSS-grid path behind `applyAutoColSpan`,
`applyAutoLayout` and `sectionFormLayout`) and `twelfthsFor` (the
twelve-track path of `sectionedGridLayout`) now ask `isWideFormField`
where they asked `isWideFieldType`. The precedence is unchanged: `span:
'full'`, then an authored `colSpan`, then the default. The author's
width still wins.
- **Where `multiple` is read.** It is read off the object-field
definition that the object-bound builders stash on the FormField
(`FormField.field`, set by `fromObjectSchema` and by `ObjectForm`'s flat
builder). It is never read off `FormField.multiple`, which a form view
entry can restate. This is the card's "只读对象字段的 `multiple`". Reading the
stash means no caller had to change: every host that lays out through
these helpers gets the rule, and the diff does not touch
`ModalForm.tsx`, `DrawerForm.tsx`, `ObjectForm.tsx`, `TabbedForm.tsx` or
`WizardForm.tsx`.
- No change to `WIDE_FIELD_TYPES`, `isWideFieldType`'s signature or
answer, or the package's `index.tsx` / `core.ts` exports. No metadata
key is added.
- `ui/packages/plugin-form/README.md`: the wide-kinds sentence names the
multi-file rule.
- `packages/spec/src/ui/view.zod.ts`: the `FormField.span` `.describe()`
said that under `'auto'` "only textarea, markdown, html, richtext and
repeater resolve to the full column count". That is no longer true, so
it now reads "only textarea, markdown, html, richtext and repeater, plus
a file or image field whose object field declares `multiple: true`,
resolve to the full column count (…); an authored `colSpan` still wins
over that default (`colSpan: 1` keeps such a field in one cell)." The
colSpan clause was corrected in round 2: `resolveColSpan` and
`twelfthsFor` check `span: 'full'`, then `colSpan`, then
`isWideFormField` (which covers both the wide types and multi file /
image). So an explicit `span: 'auto'` does not narrow any of them, and
only an authored `colSpan` does. This is description text only: no
schema, key, value or default changes, so `Clause-②: no` and
`Metadata-protocol: none` stand (L1-a REWORK 6941942506, claim amendment
6941965048). Regenerated output: `content/docs/references/ui/view.mdx`
(the `FormField` and `FormSection.fields` rows). The JSON Schema output
is gitignored, and `check:authorable-surface` regenerates it and is
green.
- `.changeset/34668-form-multi-file-full-row.md`:
`@object-ui/plugin-form` patch and `@objectstack/spec` patch (the
description text).
## Tests
New file
`ui/packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx`,
17 tests. The rendered cases read per-row counts from the real form
renderer's classes at `@md` / `@2xl` / `@4xl`, the same reading as
`dialogContainerColumns-34607`.
- Acceptance 1, dialog: flat create dialog (three wide), `full` dialog
(four wide), undeclared sections, the object's `fieldGroups`, and a
mixed-density (twelve-track) dialog. Multi image and multi file take the
row (`[1, 1, 1]`).
- Acceptance 1, page hosts: `ObjectForm` sectioned, `ObjectForm` flat
(span equals the inferred grid width), `TabbedForm`, `WizardForm`.
- Acceptance 2: single image, single file and multi-value select keep
one cell (`[2, 3, 3]`). An authored `colSpan: 1` keeps a multi image in
one cell. `span: 'full'` still widens a single file.
- Helper layer: both spellings; only the object field is read
(FormField-level `multiple` alone does not widen); `multiple` on select
/ lookup does nothing; authored `colSpan` wins; twelve-track twelfths;
`applyAutoLayout`.
- Acceptance 3: no existing pin was edited. Before this change, no
existing test in the package pinned a file / image cell width (searched
for `field:file` / `field:image` in the package's tests). The full
package suite is green unedited (below).
## Acceptance notes
- **View-level `multiple`.** A form view entry restating `multiple` over
the object field changes the widget (`sectionFields` merges
`fd.multiple`). It does not change the width, because the ruling reads
the object field only. A view that turns a single-file object field into
a multi-file widget therefore keeps one cell, and the author can widen
it with `span: 'full'`. This follows the ruling and is recorded here,
not changed.
- **`video` / `audio`.** These map to the `field:file` widget. If their
object field declared `multiple: true`, they would widen in the form but
not in the detail view, which matches on the raw type. The spec's
multi-capable types are select / lookup / file / image, so this is not
reachable through validated metadata. No card filed.
- **`ModalForm.tsx` docblock.** The `DIALOG_DEFAULT_COLUMNS` docblock
lists the wide kinds via `isWideFieldType` and does not mention
multi-file. It is still true as written. It was left alone because the
file belongs to the sibling #34604 work.
- **Studio designer.** app-shell's `ObjectFormDesigner` previews widths
with `isWideFieldType` on the raw type, so its preview does not show the
multi-file rule. Not a defect class under the card. Noted only.
- **Unchanged inputs.** An inline `customFields` member, or a form
mounted with no object schema, carries no stashed object field and keeps
the type-only answer.
## Verification
Head: `eba9da32`, a clean merge of `origin/main` f02f4f6 into
`31c82383` (no hand resolution). Since `f261912b` the plugin-form code
and tests in this PR are unchanged. The blocks after the spec block were
taken on `f261912b`; the merge block was taken on `eba9da32`.
<details><summary>After the origin/main merge (head eba9da3)</summary>
```text
git merge --no-ff origin/main (f02f4f6, 18 commits): clean, no conflict
incoming touched packages/spec and plugin-form's ModalForm.tsx / ObjectForm.tsx
overlap-check: VERDICT clean exit 0
pnpm turbo run build --filter='@object-ui/plugin-form^...' --concurrency=2 lock VERDICT command-exit 0
pnpm --filter @objectstack/spec check:generated lock VERDICT command-exit 0: All 14 generated artifacts are up to date
pnpm --filter @object-ui/plugin-form run type-check lock VERDICT command-exit 0
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/ lock VERDICT command-exit 0
Test Files 237 passed (237)
Tests 2653 passed | 1 skipped (2654)
```
</details>
<details><summary>Spec text (head 31c8238)</summary>
```text
pnpm --filter @objectstack/spec check:generated --fix (rebuilds spec first) lock VERDICT command-exit 0
before: check:docs stale; after: gen:docs, check:docs re-check green
the describe edit, the regenerated view.mdx (2 lines) and the changeset are in ONE commit, 31c8238
pnpm --filter @objectstack/spec check:generated (31c8238) lock VERDICT command-exit 0: All 14 generated artifacts are up to date
dispatch-gates --commands on 31c8238: 115 families; --ran: 115 derived / 115 run / 0 NOT-MEASURED
sequential batch: 108 exit 0. Seven non-zero in the batch, each exit 0 when re-run alone after the batch:
exit 3 -> 0: lint check:doc-formula-expressions, lint check:doc-security-posture, spec check:skill-examples,
check:docs-transcript-drift, check:dual-build-cjs-loads, check:lean-entry-closure
exit 1 -> 0: spec check:generated (re-run under the lock)
cause of the batch non-zeros: not measured (the worktree's dependency closure was not prebuilt)
pnpm check:skill-frame-freshness exit 0; pnpm check:changeset-fixed exit 0
pnpm --dir ui run check:new-line-citations exit 0 (0 new citations)
ui scripts vitest under the lock: Test Files 171 passed | 2 skipped, VERDICT command-exit 0
```
Round 1: CI on `ed2ed090` failed `Type Check · source gates`
(check:docs: `view.mdx` out of date; that commit carried the describe
edit without the regenerated page). `d48fa36d` was green on every check.
</details>
<details><summary>New test file (17/17) and ablation</summary>
```text
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/src/__tests__/multiFileFullRow-34668.test.tsx (head f261912)
Test Files 1 passed (1)
Tests 17 passed (17)
os-verify-lock: VERDICT command-exit 0
Ablation (on the 15-test version of the file, commit a52c87e): the multi-file arm of isWideFormField replaced by `return false;`
via node scripts/ablation-replace.mjs (the test imports ../autoLayout from src, so no dist leg)
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 808ab16 -> 59410cc1ad0c
Tests 12 failed | 3 passed (15)
(the 3 that stay green are the unchanged controls: single file / image and multi select keep one cell,
FormField-level multiple alone does not widen, multiple on select / lookup does nothing)
ablation-replace: ok restored: blob == HEAD (808ab16) and `git diff HEAD` is empty
```
Before / after for a `multiple: true` image in the 17-field create
dialog (three wide), per row at @md / @2XL / @4XL: before (the ablated
leg, which is origin/main's rule) `[2, 3, 3]`, one cell. After: `[1, 1,
1]`, the whole row.
</details>
<details><summary>Package suite and type-check</summary>
```text
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/ (no existing test edited)
Test Files 235 passed (235)
Tests 2633 passed | 1 skipped (2634)
os-verify-lock: VERDICT command-exit 0
(taken on a52c87e; the later commit f261912 adds only two tests to the new file and the changeset)
pnpm --filter @object-ui/plugin-form run type-check (tsc --noEmit && tsc -p tsconfig.test.json; head f261912)
os-verify-lock: VERDICT command-exit 0
tsconfig.test.json --listFilesOnly lists multiFileFullRow-34668.test.tsx: 1 hit
```
</details>
<details><summary>Local gate subset (dispatch-gates --commands, narrowed
by diff)</summary>
```text
exit 0 node scripts/check-adr-0087-registration.mjs --base origin/main
exit 0 node scripts/check-adr-0087-registration.mjs --self-test
exit 0 node scripts/check-changeset-no-major.mjs --base origin/main
exit 0 node scripts/check-closing-keyword-parity.mjs
exit 0 node scripts/check-closing-keyword-parity.mjs --self-test
exit 0 node scripts/check-comment-mask-corpus.mjs
exit 0 node scripts/check-empty-changeset.mjs --base origin/main
exit 0 node scripts/check-empty-changeset.mjs --self-test
exit 0 node scripts/check-sdui-manifest.mjs
exit 0 node scripts/check-sdui-manifest.mjs --self-test
exit 0 node scripts/ci/snapshot-next.mjs --self-test
exit 0 node scripts/pm/check-governed-queue-guard.mjs --self-test
exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test
exit 0 node scripts/release-pending-publish.mjs --self-test
exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys
exit 0 pnpm check:adr-anchors
exit 0 pnpm check:changeset-gate-self-tests
exit 0 pnpm check:closed-ceremony-text
exit 0 pnpm check:cross-package-test-inputs
exit 0 pnpm check:dispatcher-error-vocabulary
exit 0 pnpm check:driver-memory-census
exit 0 pnpm check:engine-double-contract
exit 0 pnpm check:gitlink-declared
exit 0 pnpm check:nul-bytes
exit 0 pnpm check:published-files
exit 0 pnpm check:query-options-erasure
exit 0 pnpm check:refd-timer-probe
exit 0 pnpm check:registry-log-declared
exit 0 pnpm check:rest-log-spy-declared
exit 0 pnpm check:skill-identifier-liveness
exit 0 pnpm check:test-source-alias
exit 0 pnpm check:tier-file-adoption
exit 0 pnpm check:type-check-coverage
exit 0 pnpm check:type-check-debt
exit 0 pnpm check:undeclared-dep-imports
exit 0 pnpm check:watch-hint-literal
exit 0 pnpm check:where-matcher
exit 0 pnpm check:changeset-fixed
exit 0 pnpm --dir ui exec vitest run scripts/ (lock)
exit 0 pnpm --dir ui run check:new-line-citations (VERDICT new-cross-file-line-citations: 0 new citation(s))
dispatch-gates --ran: 38 derived famil(ies) accounted for, 38 run, 0 NOT-MEASURED (head f261912)
```
Every other family (the wide-population and roster families, Type Check
UI, Test UI, Lint UI, the full farm) is CI's. See the PR check-runs.
</details>
Overlap: `node scripts/pm/overlap-check.mjs` reported `VERDICT clean
exit 0` (origin/main fecd2e9 merges cleanly; 0 open PR heads share a
file).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzgwLiKcfujYUug7sPs -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 07f2861 commit a8aa6ab
6 files changed
Lines changed: 342 additions & 9 deletions
File tree
- .changeset
- content/docs/references/ui
- packages/spec/src/ui
- ui/packages/plugin-form
- src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | | - | |
| 225 | + | |
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
| 355 | + | |
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4040 | 4040 | | |
4041 | 4041 | | |
4042 | 4042 | | |
4043 | | - | |
| 4043 | + | |
4044 | 4044 | | |
4045 | 4045 | | |
4046 | 4046 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
567 | | - | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
568 | 571 | | |
569 | 572 | | |
570 | 573 | | |
| |||
0 commit comments