Repository navigation
Commit dc66d33
feat(plugin-form): the form dialog maximizes in place like the record drawer, remembered per object (#34703)
<!-- 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 #34604
Clause-②: no
Metadata-protocol: none
repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs
## 维护者速读
- 改了什么:新建 / 编辑表单弹窗的标题栏加了放大 /
还原按钮(和记录抽屉同一个图标、同一个位置,紧挨关闭按钮左边);普通表单和带行项目的表单两种弹窗都有,并按对象记住上次的选择。
- 为什么改:长表单、带行项目的报价单在弹窗里只能用 90%
高度、受限宽度;维护者要求「展开为整页,现在右侧弹出框已经有放大缩小的图标,可以统一风格」。
- 风险与回滚:只改弹窗外框的 class,表单本身不重新挂载,已填内容、未保存提示、行项目都保留;回滚即还原本 PR,选择记录在浏览器
localStorage(键 `modal-form-maximized:OBJECT`),无数据或元数据改动。
- 先看:`ui/packages/plugin-form/src/ModalForm.tsx`(`effectiveModalSize`
里的放大覆盖、`heightClass`、`maximizeButton`)、`ui/packages/plugin-form/src/modalMaximize.ts`(按对象记忆)、`__tests__/modalMaximize-34604.test.tsx`。
-
两分钟验证:控制台打开「新建商机」,填两个字段后点标题栏右上角关闭按钮左边的放大图标:弹窗铺满、内容还在;再点还原回原尺寸;关掉重开同一对象仍是放大状态,换一个对象是原尺寸。
- 需要你做的:无,席位落地。
## What changes
- The form dialog (`ModalForm`) draws the record drawer's maximize /
restore switch in its header: the same `RecordTopBarButton`, the lucide
`Maximize2` / `Minimize2` pair at `h-3.5 w-3.5`, the same existing i18n
keys (`detail.maximize` / `detail.restoreSize`), placed just before the
close (X) button in both position and tab order. Both arms carry it: the
flat form and the `subforms` master-detail form (its own
`MobileDialogContent`).
- Maximized, the effective size is `full` (`sm:max-w-[95vw]`) whatever
the authored or inferred size, and the height cap is lifted: `sm:h-auto
sm:max-h-[90vh]` becomes `sm:h-[95dvh] sm:max-h-[95dvh]`, so the dialog
fills the window and its body scroller (not the page) scrolls a long
form. Restore puts back the exact previous classes.
- Toggling changes the content element's classes only. The form subtree
is not remounted: typed values, the dirty state that arms the discard
guard, and master-detail lines all survive (pinned by element identity).
- Every reader of the size reads the effective size, so
`dialogUndeclaredColumns(fieldCount, modalSize)` (#34607) answers four
columns for a 16+-field undeclared form when maximized, and three again
when restored.
- The choice is a per-object preference (ui AGENTS.md #8): a new
package-internal helper `modalMaximize.ts` stores
`modal-form-maximized:OBJECT` in `localStorage` (try/catch, SSR-safe;
restore removes the entry). It is re-read when a mounted dialog is
handed another object. Not re-exported from `index.tsx` or `core.ts`.
- Phone: the sheet already fills the screen, so the switch is drawn from
`sm` up only (`hidden sm:inline-flex`). The header gets `sm:pr-20` so a
long title stays clear of the two buttons.
- Clause-② `no` holds: no new locale key (the two keys exist in every
pack; only the no-provider English defaults table in `ModalForm` gains
the two entries the drawer's table carries), no new export or prop on
`@object-ui/plugin-form` or `@object-ui/components`, no spec key.
`mobile-dialog-content.tsx` is untouched (the override merges over its
base `sm:max-h-[90vh]`).
- Kept: #34599's close guard and sticky Save bar in the master-detail
arm (pinned maximized: the discard prompt still fires on the X,
`md-form-submit` still drawn); #34607's `dialogUndeclaredColumns`.
## Tests
New file
`ui/packages/plugin-form/src/__tests__/modalMaximize-34604.test.tsx` (10
tests; no shared ModalForm harness file exists, so a card-named file):
- flat arm: label/aria and icon, order before Close, `sm`-only, same
content node across toggles, restore gives back the previous width
class; typed value and same input element across two toggles, then the X
still opens "Discard changes?"; switch present with `modalCloseButton:
false`.
- preference: reopen maximized for the same object, another object
unaffected; restore forgets; a mounted dialog handed another object
takes that object's choice; a throwing `Storage` leaves the switch
working.
- columns: 16 undeclared fields read three per row at `@4xl` in the
inferred `xl`, four maximized, three restored; the typed value survives.
- master-detail arm: switch present and toggles the same content node;
header value and an added line (same input elements) survive two
toggles, Save bar drawn, the X still prompts.
No existing pin changed (`dialogDefaultLayout-12521`,
`modalViewportGutter-12593`, `modalCloseButton-11061`,
`ObjectForm.mobileFullscreen` all pass unchanged).
<details><summary>Readings at head ea132c4</summary>
- `pnpm --dir ui exec vitest run --maxWorkers=2
packages/plugin-form/src/__tests__/modalMaximize-34604.test.tsx`: Test
Files 1 passed, Tests 10 passed; lock VERDICT command-exit 0.
- `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/`:
Test Files 235 passed (235), Tests 2628 passed, 1 skipped (2629); lock
VERDICT command-exit 0.
- `pnpm --filter @object-ui/plugin-form type-check` (`tsc --noEmit &&
tsc -p tsconfig.test.json`): exit 0; `--listFiles` of
`tsconfig.test.json` lists the new test file.
</details>
<details><summary>Ablations (one-shot, restored, no permanent test
files)</summary>
Both through `scripts/ablation-replace.mjs` (anchor 1 to 0, blob moved,
restore verified blob == HEAD and `git diff HEAD` empty). The test
imports `../ModalForm` from source, so no build sits on the path.
1. `if (maximized) return 'full';` replaced by a constant-false guard:
10 of 10 tests red.
2. `key={maximized ? 'max' : 'restored'}` added to the flat arm's
content (a remount on toggle): the two flat-arm identity tests red
("expected the same dialog node", "expected the same input element"), 1
passed.
</details>
## Acceptance notes
- Before: the form dialog had no size control; the inferred size stops
at `xl` and the height at `90vh`. After: the switch above, in both arms,
remembered per object.
- Escape still runs the close guard while maximized (the drawer's Escape
restores first); not asked by the card, left as is.
- An authored `modalSize: 'full'` still shows the switch: there maximize
only lifts the height cap.
- ui AGENTS.md #2 (README / `content/docs/frontend`) was not updated:
neither page describes the dialog's runtime chrome today and both are
outside this card's file surface.
- Overlaps #34642 in ModalForm.tsx; whichever lands second merges main.
(`overlap-check`: origin/main merges cleanly; #34642 conflicts in
`ui/packages/plugin-form/src/ModalForm.tsx`, exit 1.)
## Verification
<details><summary>Local gates (derived by `dispatch-gates.mjs
--commands`, reconciled with `--ran`)</summary>
- 38 derived commands, 38 run, each exit 0 (`--ran` verdict: "38 run, 0
NOT-MEASURED (a DERIVED zero — all 38 recorded an exit code and none of
them is 3)").
- `pnpm check:new-line-citations` (ui): 0 new citations, exit 0.
- Families CI runs (Test UI, Type Check UI, Lint UI, Build and E2E UI,
the rest) are read from this PR's check-runs, not re-run locally.
</details>
---
_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 e47c1cb commit dc66d33
4 files changed
Lines changed: 543 additions & 6 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 | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
39 | | - | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| |||
511 | 517 | | |
512 | 518 | | |
513 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
514 | 526 | | |
515 | 527 | | |
516 | 528 | | |
| |||
519 | 531 | | |
520 | 532 | | |
521 | 533 | | |
| 534 | + | |
522 | 535 | | |
523 | 536 | | |
524 | 537 | | |
525 | 538 | | |
526 | 539 | | |
527 | | - | |
| 540 | + | |
528 | 541 | | |
529 | 542 | | |
530 | 543 | | |
| |||
542 | 555 | | |
543 | 556 | | |
544 | 557 | | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
545 | 565 | | |
546 | 566 | | |
547 | 567 | | |
| |||
1226 | 1246 | | |
1227 | 1247 | | |
1228 | 1248 | | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1229 | 1271 | | |
1230 | 1272 | | |
1231 | 1273 | | |
| |||
1265 | 1307 | | |
1266 | 1308 | | |
1267 | 1309 | | |
1268 | | - | |
| 1310 | + | |
| 1311 | + | |
1269 | 1312 | | |
1270 | 1313 | | |
1271 | | - | |
| 1314 | + | |
1272 | 1315 | | |
1273 | 1316 | | |
1274 | 1317 | | |
| |||
1319 | 1362 | | |
1320 | 1363 | | |
1321 | 1364 | | |
| 1365 | + | |
1322 | 1366 | | |
1323 | 1367 | | |
1324 | 1368 | | |
| |||
1332 | 1376 | | |
1333 | 1377 | | |
1334 | 1378 | | |
1335 | | - | |
| 1379 | + | |
| 1380 | + | |
1336 | 1381 | | |
1337 | 1382 | | |
1338 | | - | |
| 1383 | + | |
1339 | 1384 | | |
1340 | 1385 | | |
1341 | 1386 | | |
| |||
1416 | 1461 | | |
1417 | 1462 | | |
1418 | 1463 | | |
| 1464 | + | |
1419 | 1465 | | |
1420 | 1466 | | |
1421 | 1467 | | |
| |||
0 commit comments