You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 119c82c
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-form): pin the master-detail Save bar and guard the subform close (#34657)
<!-- 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#34599
Clause-②: no
Metadata-protocol: none
repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs
## 维护者速读
- **改了什么**:带内嵌子表的表单(报价单、项目预算这类)在弹窗、抽屉、整页里,取消 /
保存按钮现在固定在底部,滚到哪里都看得见;弹窗里填了内容再点关闭(X、Esc、点遮罩)会先弹「放弃更改?」确认,刷新页面也会提示。
- **为什么改**:以前按钮画在所有字段和行项目之后,长单据要滚到最底才能保存;子表分支关闭时也不拦截,填好的内容和行项目一按 Esc
就没了。
- **风险与回滚**:只改界面层(`@object-ui/plugin-form`),保存逻辑(`/api/v1/batch`)、按钮
test id、包的导出都没动;有问题直接回退本 PR 即可。
- **先看**:`MasterDetailForm.tsx`(操作栏的 sticky
类与未保存判定)、`ModalForm.tsx`(子表分支的关闭路径改走确认框)、`formDirtyReport.ts`(包内的未保存信号通道)。
- **两分钟验证**:在 showcase 新建一张带行项目的记录(弹窗),把弹窗滚到顶部,应能直接看到底部的取消 /
保存;在抬头输入一个字后按 Esc,应弹出「放弃更改?」。
- **需要你做的**:无,席位落地。
## What changes
- **The master-detail Save bar is pinned.** `MasterDetailForm`'s action
bar (`md-form-cancel` / `md-form-submit`, test ids unchanged) is now
`position: sticky; bottom: 0` with an opaque background, a direct child
of the form's root. Sticky resolves against the nearest scrolling
ancestor, so the same bar pins to the dialog body scroller
(`ModalForm`), the drawer content (`DrawerForm`) and the record page's
scroller (`ObjectForm` page host, `RecordFormPage`). Measured in
Chromium: sticky stops at the scroller's CONTENT edge, so a padded
scroller would show lines scrolling through the padding strip under the
bar; an `after:` strip (24px, the widest host padding) paints over it.
ADR-0035 Decision §6 stays true: the form owns its Save, and no host
draws a second footer.
- **The subform close is guarded.** A package-internal context,
`FormDirtyReportContext` (`formDirtyReport.ts`, not re-exported from the
index), carries an unsaved-input verdict up to the nearest provider:
- `ModalForm` and `DrawerForm` provide their close guard's setter around
the master-detail form they host;
- `MasterDetailForm` reports header OR lines OR row editor, and provides
its own reporters around the header form and the row editor;
- the record-form layouts the header renders through (`ObjectForm`'s
default arm, `TabbedForm`) report the renderer's existing
`onDirtyChange` verdict to it, beside their bus gate.
- Lines count as unsaved by the edit save's own row diff
(`linesUnsaved`, already the bus-hold rule): a blank ghost line is not
input, a reverted edit reads as saved. A save clears the verdict (create
remounts the header; an edit resets the header verdict and advances the
lines' baseline).
- `ModalForm`'s subform arm now routes its Dialog close (X, Escape,
backdrop) through the same `attemptClose` path and discard AlertDialog
as the flat arm, and its beforeunload guard hears the same verdict.
`DrawerForm` already routed its Sheet close through the guard; it now
hears the master-detail input. The explicit Cancel still closes at once,
as in the flat arm.
- **No conflict dialog on the subform arm, by design.** The
master-detail save goes through the header form's `submitHandler` (one
batch), which never reaches `useOccSave`; there is no OCC token to
conflict on, so none was invented.
- Exported surface: `MasterDetailFormProps`, `MasterDetailFormSchema`
and `src/index.tsx` are byte-identical (`git diff` of index.tsx is
empty, no `export`/`interface` line moved), which is what keeps
`Clause-②: no`.
## Tests
- `subformHosts.test.tsx`, new top-level describe "master-detail Save
bar is pinned to the host scroll frame": in modal, drawer and page hosts
the bar is sticky + bottom-0 + opaque, and the first ancestor that sets
an overflow is the host's own scroller (modal: the `flex-1
overflow-y-auto` body; drawer: the Sheet content; page: none inside the
component). One Save in the dialog, no `modal-form-footer` /
`drawer-form-footer`.
- `discardGuard.test.tsx`, new top-level describe "master-detail overlay
unsaved-changes guard": pristine dialog closes on the X; typed header
input prompts and "Discard" closes; an edited line alone prompts; Cancel
closes a dirty dialog at once; dirty dialog blocks unload; drawer
prompts on typed header input; the reporter goes true then false across
a create save and across an edit save (header stays mounted).
- New pins went into the two existing harness files as top-level
describes (AGENTS.md, ruling record 6583487846), not new files.
<details><summary>Readings (head c367f82 unless noted)</summary>
- `pnpm --filter @object-ui/plugin-form exec vitest run --root ../..
--maxWorkers=2 packages/plugin-form/` under the verify lock: `Test Files
233 passed (233)`, `Tests 2604 passed | 1 skipped (2605)`, VERDICT
command-exit 0.
- Re-run on the merged head 205f1d2 (origin/main 518baca merged in):
the same suite, `Test Files 233 passed (233)`, `Tests 2604 passed | 1
skipped (2605)`, VERDICT command-exit 0; type-check and the changeset /
nul-byte / type-check-coverage gates exit 0.
- `pnpm --filter @object-ui/plugin-form run type-check` (both `tsc
--noEmit` and `tsc -p tsconfig.test.json`): VERDICT command-exit 0.
- Ablations (each through `scripts/ablation-replace.mjs`, mutation
proven on disk, restored to the HEAD blob with `git diff HEAD` empty;
tests import `./ModalForm` etc. from source, so no dist leg):
- drop `sticky bottom-0` from the bar: 3 failed (the three host pins).
- ObjectForm hands the renderer the bus handler only (no report): 4
failed (header prompt in modal and drawer, unload, reporter).
- drop `linesDirty` from the verdict: 1 failed (edited line alone).
- drop the header reset in `handleSaved`: first run stayed green (a
create remounts the header, so the reset is redundant there); the
edit-save pin was added, and the re-run failed 1 (that pin).
- subform Dialog back to `onOpenChange={schema.onOpenChange}`: 2 failed
(header and line prompts).
- Chromium probe (scratch HTML, not committed): a sticky bottom-0 child
of a 24px-padded scroller rests at 276 of a 300px scroller (the content
edge); with the 24px `after:` strip the padding strip renders covered
and the scroll height is unchanged (1088 = content + bar + padding).
</details>
## Acceptance notes
- Overlaps draft #34642 (#34605) in ModalForm.tsx; area order lands this
PR first, #34642 merges main after.
- Card acceptance 1 (modal) and 2 (drawer, page): pinned structurally
and by the Chromium CSS probe; the live Console was not driven in a
browser for this PR (NOT MEASURED: live UI). The Live E2E UI job runs
the `md-form-submit` specs (acceptance 4) on this PR.
- Acceptance 3: covered for the dialog and the drawer. The record page
(`RecordFormPage`) has no close guard for the flat form either, so none
was added for the master-detail page host.
- `md-form-actions` is a new test id on the bar wrapper (for the pins);
`md-form-cancel` / `md-form-submit` are unchanged.
- The `after:` strip extends 24px below the bar in its resting position;
in every host measured the master-detail form is the last child of its
scroller, where that strip covers only the scroller's bottom padding.
## Verification
- Local gates: the `dispatch-gates.mjs --commands` list for this diff
(38 commands) plus `pnpm check:changeset-fixed` (its roster sits under
`.changeset/`), every one exit 0; `pnpm --dir ui run
check:new-line-citations`: 0 new citations. CI owns the rest (Lint UI,
Type Check UI, Test UI, Build & E2E UI, Live E2E UI, Dogfood).
---
_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>
fix(plugin-form): the master-detail Save bar stays in view, and closing a master-detail dialog with unsaved input asks first
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
A form with inline sub-tables (`subforms`) drew its Cancel and Save buttons after the last field and the last line, so in a dialog, a drawer or on the record page a long form had to be scrolled to the end before it could be saved.
11
+
12
+
-**The action bar is pinned.**`MasterDetailForm` keeps its own Cancel and Save (ADR-0035 Decision §6), and the bar now sticks to the bottom edge of whatever scroll frame hosts the form: the dialog body, the drawer, the record page. The test ids `md-form-cancel` and `md-form-submit` are unchanged.
13
+
-**Closing asks before it discards.** The master-detail arm of `ModalForm` closed on Escape, a backdrop click or the X with the typed values and edited lines gone. It now goes through the same "Discard changes?" confirmation, and the same page-unload prompt, as a form without sub-tables. Input counts when it is in the header fields, in the lines (a change the save would write; a blank line does not count) or in the open row editor. `DrawerForm` already routed its close through the guard, and now hears the master-detail form's input too. The explicit Cancel button still closes at once, and a successful save clears the guard.
14
+
15
+
Nothing changes in how the form saves (one atomic `/api/v1/batch`), and no prop or type is added to the package's exports.
0 commit comments