Skip to content

Commit fecd2e9

Browse files
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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/plugin-form': patch
3+
---
4+
5+
feat(plugin-form): a form dialog with no declared `columns` spreads a field-heavy form to three columns, and to four in a `full` dialog
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A record dialog whose form declares no `columns` drew every form two fields per row, however many fields it had. On a wide screen a long business form left most of the dialog empty. The dialog now picks its column count from the number of fields it shows:
11+
12+
- **Up to eight fields:** two per row, as before.
13+
- **Nine or more fields:** three per row, in the standard dialog sizes.
14+
- **Sixteen or more fields in a `full` dialog** (`modalSize: 'full'`): four per row.
15+
16+
The bounded `xl` dialog stops at three because its field area is already wider than the four-column breakpoint. Columns still follow the dialog's real width, so a narrow dialog and a phone show one column. Sections and the object's field groups that declare no `columns` get the same count. Long text, rich text, markdown, html and inline grid fields still take a whole row.
17+
18+
A declared `columns`, including `1`, is drawn as written, on the form and on each section. The dialog's inferred size (`lg` or `xl`) is unchanged. Full-page, tabbed and wizard forms are unchanged: a section with no `columns` still draws two per row there.
19+
20+
If your forms declare `columns: 2` only to keep the old dialog layout, you can remove it to get the wider layout.

‎ui/packages/plugin-form/README.md‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,29 @@ A sectioned form renders as ONE grid, and two keys decide its shape:
542542
| a section's `columns` | how densely THAT section fills the grid (via per-field `colSpan`) |
543543

544544
The view's `columns` wins; without it the grid takes the widest section's
545-
density, and without either it is single-column. Every sectioned host resolves it
546-
the same way — `ObjectForm` (simple), `ModalForm`, `TabbedForm`, `WizardForm` —
547-
so one piece of metadata lays out identically wherever it is
548-
rendered. (`WizardForm` has no widest-section fallback: its steps never share a
549-
viewport, so each step keeps its own authored width.)
545+
density. Every sectioned host resolves it through the same rule
546+
(`sectionedGridLayout`) — `ObjectForm` (simple), `ModalForm`, `TabbedForm`,
547+
`WizardForm`. (`WizardForm` has no widest-section fallback: its steps never share
548+
a viewport, so each step keeps its own authored width.)
549+
550+
A declared `columns` — on the view or on a section, `1` included — is drawn as
551+
written on every host. Where neither the view nor a section declares one, the
552+
count is the renderer's choice, and it differs by host:
553+
554+
| Host | Undeclared count |
555+
|---|---|
556+
| page hosts (`ObjectForm`, `TabbedForm`, `WizardForm`) | 2 per row (`UNDECLARED_SECTION_COLUMNS`) |
557+
| the form dialog (`ModalForm`) | by field count: 2 for up to eight fields, 3 from nine; 4 from sixteen in a `full` dialog (`dialogUndeclaredColumns`) |
558+
559+
The dialog's count applies to a flat form, to undeclared sections and to the
560+
object's `fieldGroups` alike. A bounded dialog (`lg` / `xl`) stops at 3 because
561+
the `xl` dialog's field area already reaches the four-column container tier;
562+
the fourth column is the `full` dialog's.
563+
564+
Every count is a container-query grid, so it is an upper bound: the form draws
565+
as many columns as its container is wide enough for, and one column below the
566+
`@md` tier (a phone, a narrow drawer). Wide field kinds (textarea, rich text,
567+
markdown, html, an inline `grid`) and `span: 'full'` fields take the whole row.
550568

551569
The grid is applied to the field container **inside** the form, never wrapped
552570
around the `<form>` (which would put the whole form in cell 1 and leave the other

‎ui/packages/plugin-form/src/ModalForm.tsx‎

Lines changed: 78 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import {
4949
filterSystemFields,
5050
inferColumns,
5151
inferModalSize,
52+
dialogUndeclaredColumns,
5253
sectionedFormColumns,
5354
sectionedGridLayout,
5455
CONTAINER_GRID_COLS,
@@ -311,25 +312,30 @@ const modalSizeClasses: Record<string, string> = {
311312
};
312313

313314
/**
314-
* How many fields per row the dialog draws where the author declared no
315-
* `columns` (objectui#12521): two from the container's `@md` tier up, one
316-
* below it, so the phone sheet keeps its single column. It rides the spec's
317-
* own `columns` / `colSpan` path, so every field takes one cell — fields of
318-
* one kind share one width — while a wide kind (`isWideFieldType`: textarea,
319-
* rich text, markdown, html, an inline `grid`) and a `span: 'full'` field take
320-
* the whole row. Line items never reach this grid: they arrive as `subforms`,
321-
* which the master-detail arm below lays out across the dialog.
315+
* The least grid the dialog draws where the author declared no `columns`
316+
* (objectui#12521): two from the container's `@md` tier up, one below it, so
317+
* the phone sheet keeps its single column. A field-heavy form draws more —
318+
* three in a bounded dialog, four in a `full` one — by
319+
* `dialogUndeclaredColumns` (objectstack-ai/objectstack#34607), whose
320+
* docblock carries the rule and the measured tier.
322321
*
323-
* It applies to a flat form with no `columns`. A SECTION that declares no
324-
* `columns` — the object's `fieldGroups` among them — gets the same count
325-
* through the one sectioned-form rule, `sectionedGridLayout`
326-
* (`UNDECLARED_SECTION_COLUMNS`), which every page host shares
327-
* (objectui#12592): an undeclared section density is the renderer's choice,
328-
* and a declared one — `1` included — is drawn as written (the
329-
* section-`columns` fork on objectui#12521, ruled 6204264665).
322+
* Every undeclared count rides the spec's own `columns` / `colSpan` path, so
323+
* every field takes one cell — fields of one kind share one width — while a
324+
* wide kind (`isWideFieldType`: textarea, rich text, markdown, html, an inline
325+
* `grid`) and a `span: 'full'` field take the whole row. Line items never
326+
* reach this grid: they arrive as `subforms`, which the master-detail arm
327+
* below lays out across the dialog.
330328
*
331-
* The flat default is dialog-only on purpose: a flat page form, a drawer and
332-
* the detail view keep `inferColumns`, which they mirror between them.
329+
* It applies to a flat form with no `columns`, and to a SECTION that declares
330+
* no `columns` — the object's `fieldGroups` among them — through the one
331+
* sectioned-form rule, `sectionedGridLayout`, handed the dialog's count: an
332+
* undeclared section density is the renderer's choice, and a declared one —
333+
* `1` included — is drawn as written (the section-`columns` fork on
334+
* objectui#12521, ruled 6204264665).
335+
*
336+
* The count is dialog-only on purpose: a sectioned page form keeps
337+
* `UNDECLARED_SECTION_COLUMNS`, and a flat page form, a drawer and the detail
338+
* view keep `inferColumns`, which they mirror between them.
333339
*/
334340
const DIALOG_DEFAULT_COLUMNS = UNDECLARED_SECTION_COLUMNS;
335341

@@ -462,55 +468,71 @@ const ModalFormBody: React.FC<ModalFormProps> = ({
462468
[schema.sections, schema.objectName, schema.formType, objectSchema, dataSource],
463469
);
464470

471+
// The fields a flat or field-group layout draws: system fields dropped, and
472+
// in create mode the server-computed ones too — what `applyAutoLayout`
473+
// filters (it filters again; the filters are idempotent). `customFields` is
474+
// already merged into `formFields` (objectui#10073).
475+
const layoutPool = useMemo(() => {
476+
const fs = filterSystemFields(formFields, objectSchema);
477+
return schema.mode === 'create' ? filterAutoGeneratedFields(fs, objectSchema) : fs;
478+
}, [formFields, objectSchema, schema.mode]);
479+
465480
// Field-group fallback (object-designer metadata): when the caller passes no
466481
// explicit sections, honor the object's declared `fieldGroups` the same way
467482
// ObjectForm's simple path does — one section per group, with flat-path
468483
// auto-layout parity (system/auto-generated fields filtered, the dialog's
469-
// default columns, wide fields spanning the row). An explicit curated
470-
// `sections` list from a form view always wins over this fallback.
484+
// undeclared count, wide fields spanning the row). An explicit curated
485+
// `sections` list from a form view always wins over this fallback. The
486+
// groups carry no `columns` of their own: the arm that draws them reads the
487+
// form's declared count, else the dialog's (objectstack-ai/objectstack#34607).
471488
const derivedSections = useMemo(() => {
472489
// `customFields` does NOT switch the fallback off (objectui#10073): the
473490
// members are merged into `formFields` above, and ObjectForm derives its
474491
// groups over that same merged pool.
475492
if (schema.sections?.length) return null;
476-
let fs = filterSystemFields(formFields, objectSchema);
477-
if (schema.mode === 'create') fs = filterAutoGeneratedFields(fs, objectSchema);
478-
const sections = deriveFieldGroupSections(fs, (objectSchema as any)?.fieldGroups, ungroupedLabel);
479-
if (!sections) return null;
480-
const columns = (clampColumns(schema.columns) ?? DIALOG_DEFAULT_COLUMNS) as 1 | 2 | 3 | 4;
493+
const sections = deriveFieldGroupSections(layoutPool, (objectSchema as any)?.fieldGroups, ungroupedLabel);
481494
// A member's definition reaches a group's body through `buildSectionFields`,
482495
// the route an explicit section's takes (objectui#10254).
483-
return sections.map((s) => ({ ...s, columns })) as ModalFormSectionConfig[];
484-
}, [schema.sections, schema.columns, schema.mode, formFields, objectSchema, ungroupedLabel]);
496+
return sections ? (sections as ModalFormSectionConfig[]) : null;
497+
}, [schema.sections, layoutPool, objectSchema, ungroupedLabel]);
485498

486499
const effectiveSections = resolvedSections?.length ? resolvedSections : (derivedSections ?? undefined);
487500

488-
// Compute auto-layout for flat fields (no sections) to determine inferred columns
489-
// (`customFields` does not switch it off: the members are merged into
490-
// `formFields`, and ObjectForm auto-lays-out that merged list — objectui#10073.)
491-
// A form that declares no `columns` lays out at the dialog's default
492-
// (objectui#12521) through the same explicit-columns route an authored
493-
// `columns` takes, so `applyAutoLayout` never infers 3–4 columns here.
494-
const flatColumns = schema.columns ?? DIALOG_DEFAULT_COLUMNS;
495-
const autoLayoutResult = useMemo(() => {
496-
if (effectiveSections?.length) return null;
497-
return applyAutoLayout(formFields, objectSchema, flatColumns, schema.mode);
498-
}, [formFields, objectSchema, flatColumns, schema.mode, effectiveSections]);
501+
// How many fields the dialog lays out — the input to its size and to its
502+
// undeclared column count.
503+
const layoutFieldCount = effectiveSections?.length
504+
? effectiveSections.reduce((n, s) => n + (Array.isArray(s.fields) ? s.fields.length : 0), 0)
505+
: layoutPool.length;
499506

500507
// The dialog's size when the author declared none (objectui#12521): bounded
501-
// — `lg` or `xl`, never `full` — and chosen from the grid that renders and
502-
// the field count, so a short form is not stretched across a wide dialog.
503-
// An authored `modalSize` (including `'full'`) is used as written.
508+
// — `lg` or `xl`, never `full` — and chosen from the declared grid and the
509+
// field count, so a short form is not stretched across a wide dialog. An
510+
// authored `modalSize` (including `'full'`) is used as written. An
511+
// undeclared grid is at least `DIALOG_DEFAULT_COLUMNS` wide whatever the
512+
// size, so the size reads that floor and never the count it then bounds
513+
// (objectstack-ai/objectstack#34607).
504514
const effectiveModalSize = useMemo(() => {
505515
if (schema.modalSize) return schema.modalSize;
506516
const columns = effectiveSections?.length
507-
? sectionedFormColumns(schema.columns, effectiveSections.map((s) => s.columns))
508-
: (autoLayoutResult?.columns ?? DIALOG_DEFAULT_COLUMNS);
509-
const fieldCount = effectiveSections?.length
510-
? effectiveSections.reduce((n, s) => n + (Array.isArray(s.fields) ? s.fields.length : 0), 0)
511-
: (autoLayoutResult?.fields.length ?? 0);
512-
return inferModalSize(Math.min(columns, inferColumns(fieldCount)));
513-
}, [schema.modalSize, schema.columns, autoLayoutResult, effectiveSections]);
517+
? sectionedFormColumns(schema.columns, effectiveSections.map((s) => s.columns), DIALOG_DEFAULT_COLUMNS)
518+
: (clampColumns(schema.columns) ?? DIALOG_DEFAULT_COLUMNS);
519+
return inferModalSize(Math.min(columns, inferColumns(layoutFieldCount)));
520+
}, [schema.modalSize, schema.columns, effectiveSections, layoutFieldCount]);
521+
522+
// The count an undeclared form or section draws in THIS dialog
523+
// (objectstack-ai/objectstack#34607): from the field count, bounded by the
524+
// dialog's size — `dialogUndeclaredColumns`.
525+
const undeclaredColumns = dialogUndeclaredColumns(layoutFieldCount, effectiveModalSize);
526+
527+
// Compute auto-layout for flat fields (no sections). A form that declares no
528+
// `columns` lays out at the dialog's undeclared count through the same
529+
// explicit-columns route an authored `columns` takes, so `applyAutoLayout`
530+
// never runs the page's inference here.
531+
const flatColumns = schema.columns ?? undeclaredColumns;
532+
const autoLayoutResult = useMemo(() => {
533+
if (effectiveSections?.length) return null;
534+
return applyAutoLayout(formFields, objectSchema, flatColumns, schema.mode);
535+
}, [formFields, objectSchema, flatColumns, schema.mode, effectiveSections]);
514536

515537
const sizeClass = modalSizeClasses[effectiveModalSize] || modalSizeClasses.default;
516538

@@ -965,13 +987,18 @@ const ModalFormBody: React.FC<ModalFormProps> = ({
965987
sec.name ? sectionLabel(schema.objectName, sec.name, sec.label || sec.name) : sec.label;
966988

967989
// The form is ONE grid. Its width is the explicit form `columns`, else the
968-
// widest section's count, an undeclared section counting two
969-
// (objectui#12521, #12592); each section then lays ITS fields out at its
990+
// widest section's count, an undeclared section counting the dialog's
991+
// undeclared count (objectui#12521, #12592; objectstack-ai/objectstack#34607);
992+
// each section then lays ITS fields out at its
970993
// own count within that grid via colSpan (objectstack-ai/objectstack#2578), exactly like the
971994
// full-page sectioned form — by the one sectioned-form rule, which
972995
// switches to a 12-track grid when the sections' counts do not all fit
973996
// the widest one (objectui#12548). It is handed the AUTHORED counts.
974-
const sectionGrid = sectionedGridLayout(schema.columns, sections.map((sec) => sec.columns));
997+
const sectionGrid = sectionedGridLayout(
998+
schema.columns,
999+
sections.map((sec) => sec.columns),
1000+
undeclaredColumns,
1001+
);
9751002
const formColumns = sectionGrid.columns;
9761003
const containerFieldClass = sectionGrid.fieldContainerClass;
9771004

@@ -1084,7 +1111,7 @@ const ModalFormBody: React.FC<ModalFormProps> = ({
10841111
// DrawerForm), so every group's fields share a single react-hook-form
10851112
// instance and the footer submit collects them all.
10861113
if (derivedSections?.length) {
1087-
const columns = (Number(derivedSections[0]?.columns) || 1) as 1 | 2 | 3 | 4;
1114+
const columns = (clampColumns(schema.columns) ?? undeclaredColumns) as 1 | 2 | 3 | 4;
10881115
const allFields: FormField[] = [];
10891116
derivedSections.forEach((section, index) => {
10901117
// FLS first, so a group whose every field is non-readable drops its

0 commit comments

Comments
 (0)