Skip to content

fix(plugin-form): pin the master-detail Save bar and guard the subform close - #34657

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-34599-subform-sticky-footer
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-34599-subform-sticky-footer

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread
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.
Readings (head c367f82 unless noted)
  • 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).

Acceptance notes

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

…m close

MasterDetailForm's action bar sticks to the bottom of the hosting scroll
frame (dialog body, drawer, record page). The master-detail form reports
its unsaved input (header, lines, row editor) through a package-internal
context into the ModalForm/DrawerForm close guard, and the ModalForm
subform arm routes its close paths through the discard dialog.

Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 17, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs

Final green head for L1 · 2026-11-17T05:24Z
Head-sha: 205f1d23332c6ca732318223580c3a6ce2d2b0b6

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzhshTXCAmv9KJXRZkB

席位核对 · L1 (seat 3, L1-a) · 2026-11-17T05:26Z

L1: ACCEPT
Head-sha: 205f1d2
Card: #34599 (triage 6937202657) · claim 6937484576 · os-dev-report 6938952715 (written before pr_create, so it reads blocked / pr: null; the code is this head)

Must-fix

None.

Should-fix

None.

Readings that hold

Item Reading
PR shape Draft, base main, Fixes #34599; no other closing verb in the body. No !, no (narrowing): no dogfood battery owed. mergeable_state clean.
Scope 9 files, all inside claim 6937484576 (ui/packages/plugin-form/src/** and root .changeset/): MasterDetailForm.tsx, ModalForm.tsx, DrawerForm.tsx, ObjectForm.tsx, TabbedForm.tsx, the new formDirtyReport.ts, two existing test files, the changeset. No locale or e2e file moved.
ADR-0035 Decision §6 The bar stays in MasterDetailForm, now sticky bottom-0 z-10 bg-background with an opaque after: strip, as a direct child of the form's root; neither ModalForm nor DrawerForm draws a footer in its master-detail arm (pinned: one Save in the dialog, no modal-form-footer / drawer-form-footer). The form still owns its Save.
Clause-② no (the claim's condition) formDirtyReport.ts (FormDirtyReportContext, useReportedDirtyChange) is imported only inside the package: neither src/index.tsx (.) nor src/core.ts (./core) names it. MasterDetailFormProps / MasterDetailFormSchema have no hunk; the only new attribute is the data-testid="md-form-actions" on the bar wrapper. Metadata-protocol: none holds: no schema key. Body, changeset and claim agree.
Hosts without a provider useReportedDirtyChange(onBusDirtyChange) returns a useCallback over [onBusDirtyChange, report]. With no provider report is null, so the callback only calls the bus handler, and its identity stays stable because useRecordInvalidation's handlers come from a one-time useState initialiser (recordInvalidation.ts:102). Every ObjectForm / TabbedForm outside a master-detail overlay therefore behaves as before, with no extra resubscription of the renderer's dirty watcher.
The verdict MasterDetailForm reports headerDirty || rowEditorDirty || linesDirty to the nearest provider and wraps the header and the row editor in providers of its own, so neither reaches the host directly. linesDirty is the edit save's own linesUnsaved diff (a blank ghost line is not input). The row-editor flag clears when the editor closes, the header flag clears in handleSaved, and unmount reports false.
The close path The master-detail Dialog now uses the same handleDialogOpenChange → attemptClose(false) as the flat arm, and the discard AlertDialog is rendered inside MobileDialogContent in both arms (the same nesting rationale, now one shared element). attemptClose honours confirmOnDiscard && isDirty, so confirmOnDiscard: false still closes at once (plugins.mdx:149 stays true, and now holds for the master-detail arm too). Explicit Cancel passes viaCancel and closes without asking, as in the flat arm.
No conflict dialog on the subform arm Agreed with the dev's reading: the master-detail save goes through the header form's submitHandler into one /api/v1/batch, not useOccSave, so there is no OCC token to conflict on. The changeset says nothing about conflicts, which is right.
Sticky mechanics In ModalForm the form sits inside div.flex-1.overflow-y-auto with only Suspense and the provider (no DOM) between, so the bar resolves against the dialog body scroller. The pins assert that the first overflow ancestor is the host's own scroller in all three hosts. The after: strip needs a positioned parent, which sticky is.
Tests in harness files New pins are top-level describes in the existing subformHosts.test.tsx (3) and discardGuard.test.tsx (8), per AGENTS.md ruling 6583487846; no card-named file. Five ablations, each restored to the HEAD blob, turn the matching pins red (the header-reset one only after an edit-save pin was added, as reported).
Docs No content/docs or skills sentence places the master-detail Save bar or says its dialog closes without asking; plugins.mdx:149 (confirmOnDiscard) becomes more accurate. Nothing is made false.
Changeset Names @object-ui/plugin-form, the one package whose src moved. Every sentence matches the diff, including "test ids md-form-cancel and md-form-submit are unchanged" and "no prop or type is added to the package's exports".
Tests Real commands with output: plugin-form 233 files / 2604 passed on c367f82d and again on this merged head; type-check exit 0; 38 derived gates exit 0.
Tier check-governed-merges --pr 34657: NOT governed, 473 lines (+432/−41). Tier S, lands through o3-B.
CI on this head 52 check-runs: all success or skipped. Test UI (aggregate plus every planned shard), Type Check UI, Lint UI, Build & E2E UI, Live E2E UI (the md-form-submit specs, acceptance 4), Test Core, Check Changeset, PR-body guards, Lint & Repo Gates and TypeScript Type Check are all success.

Notes

  1. Not driven in the live Console (declared). The sticky claim rests on the structural pins plus the dev's Chromium probe. A glance at a long quote dialog in showcase is the cheap confirmation if the landing area boots it.
  2. Reporter reach. Any ObjectForm / TabbedForm rendered inside MasterDetailForm but outside the header and row-editor providers (the line area) would report straight to the host's guard. Today nothing there renders one, so this is a shape to remember, not a defect.
  3. Out of scope, noted by the dev: the plain DrawerForm footer scrolls with its content on a long form, and RecordFormPage has no close guard for any form. Both may deserve cards; neither is a bar here.
  4. Landing order: this PR lands before draft feat(plugin-form): section navigation for stacked sectioned forms #34642 (分组表单:加分组导航,点一下滚到对应分组,并标出还有必填未填的分组 #34605); feat(plugin-form): section navigation for stacked sectioned forms #34642 then merges main and resolves ModalForm.tsx (both touch the dialog body). feat(plugin-form): an undeclared form dialog spreads a field-heavy form to three columns, four in a full dialog #34645 (表单弹窗:作者没写列数时按容器宽度排到 3–4 列,弹窗尺寸随之放大 #34607) also touches ModalForm.tsx in disjoint hunks.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs

Landing · area o3-B · 2026-11-17T05:27Z

Probe Reading
L1 ACCEPT 6939477698 at 205f1d23332c6ca732318223580c3a6ce2d2b0b6 (= current head)
Checks on head 39 success, 13 skipped, 0 failure / pending; mergeable_state: clean
check-governed-merges.mjs --pr 34657 NOT governed; 473 changed lines ≤ 3000 (Tier S)
K (first-parent, merge-base..origin/main) 11 < 15; no merge=os-regen path in the diff

State change: ready for review + auto-merge (merge queue). Card #34599 closes on merge via Fixes; then draft #34642 (#34605) merges main.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 05:28
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 119c82c Nov 17, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-34599-subform-sticky-footer branch November 17, 2026 05:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

带内嵌子表的表单弹窗:取消 / 保存不固定在底部,长表单要滚到最下面才看得到

2 participants