Repository navigation
Commit fecd2e9
feat(plugin-form): an undeclared form dialog spreads a field-heavy form to three columns, four in a full dialog (#34645)
<!-- 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 #34607
Clause-②: no
Metadata-protocol: none
repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs
## 维护者速读
- **改了什么**:表单弹窗在作者没写 `columns` 时,不再固定 2 列:字段多(9 个以上)的表单在标准弹窗里排 3 列,在
`full` 弹窗里(16 个以上字段)排 4 列;窄屏仍 1 列。分组、对象字段分组同样处理。
- **为什么改**:维护者原话「目前默认只有两列字段,对于复杂的业务表单,宽屏时候非常浪费」。xl 弹窗的字段区实测宽 61rem,已过 4
列断点(56rem),所以标准弹窗封顶 3 列、放大(full)才到 4 列,正好对上验收「xl 弹窗 3 列,放大后 4 列」。
- **风险与回滚**:只动弹窗;整页、向导、分页签表单输出不变(有对照测试)。作者显式写了 `columns`(含 `1`)的照写。回滚即
revert 本 PR。HotCRM 很多表单显式写了 `columns: 2`,所以在去掉这些声明之前 HotCRM 看不到变化(本 PR
不碰 hotcrm)。附件(file / image)在本 PR 里仍占一格:改成独占整行要动共享的
`WIDE_FIELD_TYPES`,会连带改变整页、抽屉和详情布局,与「不改整页表单的现有推断」冲突,席位已把这个问题提交维护者。
- **先看**:`ui/packages/plugin-form/src/autoLayout.ts` 的
`dialogUndeclaredColumns`(封顶规则);`ui/packages/plugin-form/src/ModalForm.tsx`
的 `effectiveModalSize` / `undeclaredColumns`
两段(尺寸先算、列数后算,不循环);`__tests__/dialogContainerColumns-34607.test.tsx`。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/plugin-form/src/__tests__/dialogContainerColumns-34607.test.tsx`,预期
14 个用例全部通过。
- **需要你做的**:无,席位落地。
## What changes
A form dialog whose author declared no `columns` drew every form two per
row. It now takes its count from `dialogUndeclaredColumns(fieldCount,
modalSize)` (new, dialog-only, in `autoLayout.ts`):
- `inferColumns` of the fields the dialog lays out, **at least 2** (the
old fixed default, so a form of up to eight fields draws exactly what it
drew before);
- **at most 3** in a bounded dialog, **4 only in a `full` one**.
Measured, not assumed: the `xl` dialog is `sm:max-w-5xl` (64rem) and its
`@container` scroller pads `sm:px-6`, so the field container is 61rem
wide, over the `@4xl` tier (56rem). A literal `containerGridColsFor(4)`
would therefore draw four columns in `xl`, against acceptance 1 (「xl
弹窗里是 3 列」). The size cap is what makes the acceptance true.
The count reaches all three dialog arms: the flat form (fed to
`applyAutoLayout` through the explicit-columns route), the object's
`fieldGroups` fallback (derived groups no longer stamp a fixed
`columns`; the arm reads the form's declared count, else the dialog's),
and authored sections (`sectionedGridLayout` takes a new optional third
argument, `undeclared`).
Dialog-only, per the claim's corrected premise:
`UNDECLARED_SECTION_COLUMNS`, and the defaults of `sectionColumnsFor`,
`sectionedFormColumns` and `sectionedGridLayout`, are unchanged. The
three functions gained an optional trailing `undeclared` parameter
defaulting to that constant; `ObjectForm`, `TabbedForm` and `WizardForm`
do not pass it. None of the touched symbols is in the package's
published entries (`index.tsx`, `core.ts`), so the public surface is
byte-unchanged.
Card items:
1. Undeclared dialog grid follows the container tiers: done, with the
size cap above.
2. Size inference allows `xl` for field-heavy forms: already true on
`main`, and unchanged. The size reads the declared grid or the floor of
2, never the count it then bounds, so there is no cycle. Proof: an
undeclared grid is at least 2 either way, so `inferModalSize(min(grid,
inferColumns(n)))` gives the same answer as before for every input.
3. Wide kinds at 4 columns: textarea, rich text, markdown, html and
inline `grid` take the whole row at every tier (pinned at 4 columns).
**Attachments (`file` / `image`) stay one cell in this PR.** They are
not in the shared `WIDE_FIELD_TYPES`, and adding them there would also
change page, drawer and detail layouts, which conflicts with
「不改整页表单的现有推断」. No code changes for them here. The seat is taking that
question to the maintainer (claim amendment 6938698182).
4. A declared `columns` is drawn as written: pinned for `2` and `1`, on
the form and on a section.
Maximize / full-page toggle is #34604. Acceptance 1's 「放大后是 4 列」 is
shown under the existing authored `modalSize: 'full'`.
### Before / after (sixteen undeclared fields, fields per row at `@md` /
`@2xl` / `@4xl`; below `@md` always 1)
| Surface | `main` (97defd6) | this PR |
|---|---|---|
| dialog, inferred `xl` | 2 / 2 / 2 | 2 / 3 / 3 |
| dialog, `modalSize: 'full'` | 2 / 2 / 2 | 2 / 3 / 4 |
| dialog, declared `columns: 2` | 2 / 2 / 2 | 2 / 2 / 2 |
| dialog, five fields | 2 / 2 / 2 | 2 / 2 / 2 |
| `ObjectForm` sectioned page, undeclared | 2 / 2 / 2 | 2 / 2 / 2 |
## Tests
- New `__tests__/dialogContainerColumns-34607.test.tsx` (14 cases)
covers acceptance 1 (xl, full, phone, wide kinds at 4), acceptance 2
(declared 2 and 1, a declared section beside an undeclared one),
undeclared sections and `fieldGroups`, the light-form floor, and the
page controls: `ObjectForm` sectioned and flat, plus
`sectionedGridLayout` with no third argument.
- Pins moved, with reason (acceptance 3):
- `dialogDefaultLayout-12521.test.tsx`: its twelve-field fixture
(`inferColumns` gives 3) now draws the three-wide grid. Four
expectations moved from the 2-wide grid and `@md:col-span-2` to the
3-wide grid and `['@md:col-span-2', '@2XL:col-span-3']`. The
phone-column check now reads "every multi-column tier is a container
query" in place of "every tier is `@md`". Size, authored-layout and
light-form pins are unchanged.
- `undeclaredSectionDensity-12592.test.tsx`: in the page-host case
"every section undeclared", the byte-equality with the dialog is
replaced. The page still reads 2 / 2 / 2 (unchanged), and the dialog
reference now reads 2 / 3 / 3. The light `MIXED` case still matches the
dialog byte for byte.
- `mixedSectionColumns-12548`, `sectionColumns.test.tsx`,
`modalFieldGroups.test.tsx`, `autoLayout.test.ts`,
`modalViewportGutter-12593`, and app-shell
`AppContent.recordDialogInterimBound-12521` /
`AppContent.formViewModalSize-12803` needed no change; all of them pass
as they are.
<details><summary>Readings</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/`:
`Test Files 234 passed (234)` · `Tests 2607 passed | 1 skipped (2608)` ·
lock `VERDICT command-exit 0`
- app-shell pins (`AppContent.recordDialogInterimBound-12521`,
`AppContent.formViewModalSize-12803`): `Test Files 2 passed (2)` ·
`Tests 21 passed (21)`
- `pnpm --filter @object-ui/plugin-form type-check` (`tsc --noEmit &&
tsc -p tsconfig.test.json`): `VERDICT command-exit 0`
- Ablation, once, via `scripts/ablation-replace.mjs` on committed HEAD:
anchor `const cap = modalSize === 'full' ? 4 : 3;` replaced by `const
cap = 4;` (anchor 1 to 0, blob `6c11ba904537` to `0512e09117ac`). Then
`dialogContainerColumns-34607`: `Tests 5 failed | 9 passed (14)` (xl
three-wide, declared-section beside undeclared, undeclared sections,
fieldGroups, helper). Restored: blob equals HEAD, `git diff HEAD` empty.
The test file imports `../ModalForm` / `../autoLayout` from source, so
no dist leg applies.
</details>
<details><summary>Fix round 1 readings (head 7ec78e2, README
only)</summary>
- `dispatch-gates --commands --repo objectstack-ai/objectstack
ui/packages/plugin-form/README.md`: 19 families, every one `exit 0`.
`--ran` reconciliation: `19 derived famil(ies) accounted for — 19 run, 0
NOT-MEASURED (a DERIVED zero …)`.
- ui `pnpm check:new-line-citations`: `0 new citation(s)`, exit 0.
- `overlap-check` before the push: `VERDICT clean exit 0` (origin/main
518baca, and #34642 shares `ModalForm.tsx`; both merge cleanly).
- No code changed this round, so the round-0 test readings stand.
</details>
## Acceptance notes
- Card item 3, attachments: `file` / `image` stay one cell in this PR,
in the dialog and on the page alike. Making them wide in the shared
`WIDE_FIELD_TYPES` would change page, drawer and detail layouts, which
conflicts with 「不改整页表单的现有推断」. The seat is taking that question to the
maintainer.
- `ui/packages/plugin-form/README.md` § "Column width of a sectioned
form" was stale: it said an undeclared sectioned form "is
single-column". It now names the page hosts' default (2 per row) and the
dialog's own undeclared count (2 to 3 by field count, 4 in a `full`
dialog). It also says that a declared `columns` is drawn as written. The
file was added to the surface by claim amendment 6938698182; this was
fix round 1.
- HotCRM declares `columns: 2` on many forms, so HotCRM shows no change
until those declarations go. hotcrm is not touched.
## Verification
Local gates follow the `dispatch-gates --commands` list derived for this
diff; readings are in the report comment. Browser check: NOT MEASURED
(jsdom evaluates no container query). The tier claim rests on the class
reading in the tests plus the 64rem − 3rem = 61rem ≥ 56rem arithmetic
above.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs)_
🤖 Generated with [Claude Code](https://claude.com/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 d9fabb2 commit fecd2e9
7 files changed
Lines changed: 463 additions & 77 deletions
File tree
- .changeset
- 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 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
550 | 568 | | |
551 | 569 | | |
552 | 570 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
52 | 53 | | |
53 | 54 | | |
54 | 55 | | |
| |||
311 | 312 | | |
312 | 313 | | |
313 | 314 | | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
322 | 321 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
330 | 328 | | |
331 | | - | |
332 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
333 | 339 | | |
334 | 340 | | |
335 | 341 | | |
| |||
462 | 468 | | |
463 | 469 | | |
464 | 470 | | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
465 | 480 | | |
466 | 481 | | |
467 | 482 | | |
468 | 483 | | |
469 | | - | |
470 | | - | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
471 | 488 | | |
472 | 489 | | |
473 | 490 | | |
474 | 491 | | |
475 | 492 | | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
| 493 | + | |
481 | 494 | | |
482 | 495 | | |
483 | | - | |
484 | | - | |
| 496 | + | |
| 497 | + | |
485 | 498 | | |
486 | 499 | | |
487 | 500 | | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
499 | 506 | | |
500 | 507 | | |
501 | | - | |
502 | | - | |
503 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
504 | 514 | | |
505 | 515 | | |
506 | 516 | | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
514 | 536 | | |
515 | 537 | | |
516 | 538 | | |
| |||
965 | 987 | | |
966 | 988 | | |
967 | 989 | | |
968 | | - | |
969 | | - | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
970 | 993 | | |
971 | 994 | | |
972 | 995 | | |
973 | 996 | | |
974 | | - | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
975 | 1002 | | |
976 | 1003 | | |
977 | 1004 | | |
| |||
1084 | 1111 | | |
1085 | 1112 | | |
1086 | 1113 | | |
1087 | | - | |
| 1114 | + | |
1088 | 1115 | | |
1089 | 1116 | | |
1090 | 1117 | | |
| |||
0 commit comments