Skip to content

Commit 6e2838c

Browse files
fix(plugin-form): the master-detail dialog Save bar sits at the dialog bottom; section nav follows a scroll inside the click hold (#34848)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBU5y97XtBcJ8qSLSR3B3Djd)_ repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs Fixes #34819 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:带内嵌子表的新建/编辑弹窗,「取消 / 创建」按钮栏改为固定在弹窗底部(不再随滚动区上浮);分组导航在点击后的 800ms 保持期结束时再按滚动位置重算一次高亮。 - 为什么改:按钮栏原是滚动区里的 sticky 元素,停在滚动区内边距之上,滚到底还会再上移,下方留白;点完分组立刻提交校验失败时,跳回顶部的滚动落在保持期内被忽略,高亮停在原分组。 - 风险与回滚:只动 plugin-form 三个文件加一个内部 context 文件;抽屉与整页表单仍走原 sticky 路径,结构未变。回滚即 revert 本 PR。 - 先看:`ui/packages/plugin-form/src/MasterDetailForm.tsx`(根节点分 frame / flow 两种布局的那段)、`ModalForm.tsx`(子表分支改用 `MasterDetailFrameContext`)、`FormSectionNav.tsx`(保持期结束重算与「到底时保留点击的分组」)。 - 两分钟验证:showcase 打开任一带内嵌子表对象的「新建」弹窗(如 Invoice),滚到任意位置,按钮栏下沿到弹窗下沿应恒为 25px(24px 内边距 + 1px 边框),与无子表弹窗的页脚一致。 - 需要你做的:无,席位落地。 ## What changes - **Save bar (item 1).** `ModalForm`'s master-detail arm no longer wraps `MasterDetailForm` in an overflow scroller. It hands the form a frame through a new package-internal context, `MasterDetailFrameContext` (`masterDetailFrame.ts`, not re-exported from the package index; no prop or schema key added to any exported type). With a frame, `MasterDetailForm` lays out as a flex column: its body (header form, line items, row editor) scrolls in its own box (`md-form-body`, the flat arm's body gutters and `@container`), and the action bar is the `shrink-0` row below it, outside the scrolled content, with the flat arm footer's padding. Without a frame (the drawer, the record page) the form renders exactly the old DOM with the sticky bar. The form still owns its Save (ADR-0035 Decision §6); the dialog draws no footer, and the close guard is unchanged. - **Section navigation (item 2).** `FormSectionNav` measures once more when the 800 ms click hold ends, so a scroll that landed inside the hold is followed. At the very bottom of a short tail, the section the last click picked keeps the highlight while its heading is in view (otherwise the last section, as before); the click preference is dropped as soon as a measure finds the form away from the bottom. - Nav counts, the maximize button and the rest of #34599 are untouched. ## Why Measured live (showcase on this branch's base `c513d62a`, isolated backend plus the Console dev server, Chromium at 1280×900). Showcase has no master-detail object whose create dialog draws two or more sections, so for the reproduction the `showcase_invoice` header fields were given three field groups in an uncommitted local edit (restored afterwards; not in this diff). That dialog measured 45..855, the same box as the card's. - **Gap cause.** The bar was `sticky bottom-0` inside the dialog body scroller (`py-4`). Sticky stops at the scroller's content edge, so the bar's bottom sat 16 px (the scroller's bottom padding) plus the dialog's own 24 px padding (`sm:p-6`, which the content's `p-0` does not override from `sm` up) plus 1 px border above the dialog's bottom: 41 px idle; the Create button 53 px (card: about 55). The sticky box also cannot leave its containing block (the form root), so anything in the scroll content past the root lifts it with the scroll: here the bar's own `after:` strip, 8 px (41 to 49 at the end). The card's 134 px at 条款 was not reproduced on showcase; it is the same mechanism with more content past the form root in that form. - **Highlight cause.** The scroll spy skips every scroll event during the 800 ms hold a click starts, and nothing measured after the hold. Clicking the last entry and submitting at once with the required fields empty: the scroll back ran 13 scroll events on the body scroller, all inside the hold, and ended at `scrollTop` 0 with the first section marked "· 2" and the highlight still on the last section. Submitting 1200 ms after the click (the hold over) followed correctly, so the defect is the hold window. ## Verification **Merged head `d603500f44`.** `git merge --no-ff origin/main` at `7752cac7` (23 commits behind) merged with no conflicts and no hand resolution; `git show --remerge-diff d603500` is empty, and the branch delta against origin/main is still exactly the 7 files of this change. On the merged head, after `pnpm install --frozen-lockfile` and rebuilding the plugin-form^... closure (turbo, 52/52): `pnpm --filter @object-ui/plugin-form run type-check` exit 0 (0 `error TS`); `vitest run packages/plugin-form/` Test Files 237 passed (237), Tests 2658 passed | 1 skipped (lock VERDICT command-exit 0); `overlap-check` clean exit 0 against origin/main `d947a93cf8` and 0 PR heads. The browser measurements below were taken on `626ff4da2a`; origin/main changed no file under `ui/packages/plugin-form` in the merged range. Bar bottom to dialog bottom, `showcase_invoice` create dialog (grouped as above), idle / mid-scroll / end: | viewport | theme | size | before | after | |---|---|---|---|---| | 1280×900 | light | normal (45..855) | 41 / 41 / 49 | 25 / 25 / 25 | | 1280×900 | dark | normal (45..855) | 41 / 41 / 49 | 25 / 25 / 25 | | 1280×900 | light | maximized (23..878) | 41 / 41 / 49 | 25 / 25 / 25 | | 1280×900 | dark | maximized (23..878) | 41 / 41 / 49 | 25 / 25 / 25 | | 390×844 | light | phone sheet (0..844) | 16 / 16 / 24 | 0 / 0 / 0 | | 390×844 | dark | phone sheet (0..844) | 16 / 16 / 24 | 0 / 0 / 0 | Reference: a dialog without a sub-table (`showcase_account` create) measures footer bottom to dialog bottom 25 px at 1280×900 (24 px padding + 1 px border), so 25 is "the dialog's padding" the card asks for; at phone width the sheet has no padding. The Create button now sits 37 px above the dialog bottom, the same as the flat arm's. Highlight, same dialog after the fix: click the last entry and submit at once: highlight on the first section (was: the last). Controls: click the second / last entry and wait 1500 ms: the highlight stays on the clicked entry; sampled every 50 ms through a jump from the top to the last entry (30 samples): only the clicked entry was ever highlighted. ## Tests - `subformHosts.test.tsx`: a new top-level `describe` for #34819 pins the dialog frame: the bar is not sticky and paints no `after:` strip, it is the `shrink-0` row right after `md-form-body`, no element between it and the dialog sets an overflow, the form root and the dialog frame are `flex min-h-0 flex-1 flex-col`, one Save and no `modal-form-footer`; the same after toggling maximize. The #34599 block keeps the drawer and page cases (sticky), and its dialog case moved into the new block because the structure it pinned is what this change replaces. - `FormSectionNav.test.tsx`: a new top-level `describe` for #34819 on a fixture scroller with set geometry: a scroll back to the top inside the hold is followed when the hold ends; one after the hold is followed; CONTROL: the jump does not highlight the sections it passes (samples through the hold and after it); CONTROL: at the bottom of a short tail the clicked section keeps the highlight when the hold ends, and a hand scroll to the bottom still reads as the last section. - New pins went into the components' existing harness files rather than a card-named file, per the AGENTS.md shared-harness rule. <details><summary>Test and ablation readings (head 626ff4d)</summary> - `vitest run packages/plugin-form/` (whole package): Test Files 237 passed (237), Tests 2658 passed, 1 skipped; lock VERDICT command-exit 0. - `pnpm --filter @object-ui/plugin-form run type-check`: exit 0, 0 `error TS`; `tsc -p tsconfig.test.json --listFilesOnly` lists both edited test files. - eslint on the six touched source and test files: 0 errors; warning counts equal to the base per file; `masterDetailFrame.ts` clean. - Ablation A (drop the re-measure at hold end, `ablation-replace.mjs`, marker `ABLATION-34819-A`): 1 failed, "follows a scroll back to the top that lands inside the click hold, once the hold ends" (expected Section 0, received Section 2); restored, blob equals HEAD, `git diff HEAD` empty. - Ablation B (bottom rule back to "always the last section", `ABLATION-34819-B`): 1 failed, the short-tail CONTROL (expected Section 2, received Section 3); restored to HEAD. - Ablation C (dialog provides no frame, `ABLATION-34819-C`): both #34819 bar pins failed; restored to HEAD. - Ablation D (frame bar made sticky again, `ABLATION-34819-D`): both #34819 bar pins failed (`sticky` asserted false); restored to HEAD. </details> <details><summary>Gates (head 626ff4d)</summary> `node scripts/pm/dispatch-gates.mjs --commands` derived 38 families from the 7-path change set; all 38 ran locally with exit 0 (each exit captured before any pipe), and `--ran` reconciled 38 derived, 38 run, 0 not measured, 0 unrun. `node scripts/check-new-cross-file-line-citations.mjs`: 0 new citations. `overlap-check`: clean exit 0 against origin/main and 0 PR heads, before each push. The full CI farm is CI's. </details> ## Acceptance notes - The record dialog's content keeps `sm:p-6` from `MobileDialogContent` because the `p-0` the dialog passes does not override a variant class; both arms draw inside that 24 px padding, and the header's own `sm:pt-6` adds to it. Left as is: the card's target is the dialog's padding, which is this value. - In the master-detail arm the section navigation is the header form's own strip, `sticky top-0` inside the body scroller, so content scrolls through the scroller's 16 px top padding above it (visible in the screenshots of both the old and the new layout). Not changed here. - The drawer host keeps the sticky bar; it was not measured in this change. - The reproduction used a local field-group edit of `showcase_invoice`; no committed example has a master-detail create dialog with two or more sections. --- _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 aa5a7d0 commit 6e2838c

7 files changed

Lines changed: 349 additions & 32 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/plugin-form': patch
3+
---
4+
5+
fix(plugin-form): the master-detail record dialog keeps its Save bar at the dialog's bottom, and the form section navigation follows a scroll that lands inside its click hold
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
**Save bar.** A record dialog whose form carries an inline sub-table (`subforms`) drew the master-detail form's Save bar as a sticky box inside the dialog's body scroller. A sticky box stops at its scroller's content edge, so the bar floated above the dialog's bottom by the scroller's bottom padding, and rose further as the body scrolled past the form's own end. The dialog now hands the form a frame of fixed height: the form scrolls its body in a box of its own and draws the bar as the row below it, outside the scrolled content. From the bar's bottom to the dialog's bottom is now the dialog's padding at every scroll position, maximized too — the same distance as the footer of a dialog without a sub-table. The form still owns its Save (ADR-0035 Decision §6), the close guard is unchanged, and the drawer and the record page keep the sticky bar.
11+
12+
**Section navigation.** After a click on a section entry, the navigation holds the highlight for 800 ms so the jump does not light up every section it passes. A scroll that landed inside that hold was never measured, so a refused submit right after a jump left the highlight on the clicked section while the form showed its first error. The navigation now measures once more when the hold ends. At the bottom of a short tail, where several headings are in view, the section the click picked keeps the highlight.

‎ui/packages/plugin-form/src/FormSectionNav.test.tsx‎

Lines changed: 138 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
*/
2323

2424
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
25-
import { render, screen, fireEvent, waitFor, within, cleanup } from '@testing-library/react';
25+
import { render, screen, fireEvent, waitFor, within, cleanup, act } from '@testing-library/react';
2626
import React from 'react';
2727
import { registerAllFields } from '@object-ui/fields';
2828
import { ModalForm } from './ModalForm';
2929
import { ObjectForm } from './ObjectForm';
30+
import { FormSectionNav } from './FormSectionNav';
3031

3132
registerAllFields();
3233

@@ -205,3 +206,139 @@ describe('ObjectForm section navigation (objectstack#34605)', () => {
205206
expect((scrollIntoView.mock.contexts[0] as HTMLElement).getAttribute('data-form-section')).toBe('__section_description');
206207
});
207208
});
209+
210+
/**
211+
* objectstack#34819 — the highlight follows the scroll position, including a
212+
* scroll that lands inside the hold a click starts: a refused submit taking
213+
* the form back to its first error right after a jump left the highlight on
214+
* the section the click had picked.
215+
*
216+
* jsdom does no layout, so the scroller and its headings are a fixture whose
217+
* geometry the test sets: the scroller's box spans 100..700, each heading sits
218+
* at its offset in the content minus `scrollTop`.
219+
*/
220+
describe('FormSectionNav highlight follows the scroll position after a click (objectstack#34819)', () => {
221+
const VIEW_TOP = 100;
222+
const VIEW_HEIGHT = 600;
223+
224+
function mountFixture(offsets: number[], contentHeight: number) {
225+
const keys = offsets.map((_, i) => `s${i}`);
226+
let scrollTop = 0;
227+
const host = render(
228+
<div>
229+
<FormSectionNav
230+
items={keys.map((key, i) => ({
231+
key,
232+
label: `Section ${i}`,
233+
anchorId: `anchor-${key}`,
234+
errorCount: 0,
235+
collapsed: false,
236+
expand: () => {},
237+
}))}
238+
/>
239+
<div data-testid="fixture-scroller" style={{ overflowY: 'auto' }}>
240+
{keys.map((key) => (
241+
<div key={key} id={`anchor-${key}`} />
242+
))}
243+
</div>
244+
</div>,
245+
);
246+
const scroller = screen.getByTestId('fixture-scroller');
247+
const rect = (top: number, height: number) =>
248+
({ top, bottom: top + height, height, left: 0, right: 0, width: 0, x: 0, y: top, toJSON: () => ({}) }) as DOMRect;
249+
scroller.getBoundingClientRect = () => rect(VIEW_TOP, VIEW_HEIGHT);
250+
Object.defineProperty(scroller, 'clientHeight', { configurable: true, get: () => VIEW_HEIGHT });
251+
Object.defineProperty(scroller, 'scrollHeight', { configurable: true, get: () => contentHeight });
252+
Object.defineProperty(scroller, 'scrollTop', { configurable: true, get: () => scrollTop });
253+
keys.forEach((key, i) => {
254+
document.getElementById(`anchor-${key}`)!.getBoundingClientRect = () => rect(VIEW_TOP + offsets[i] - scrollTop, 20);
255+
});
256+
/** Move the scroller and let the spy's frame run. */
257+
const scrollTo = (top: number) => {
258+
scrollTop = top;
259+
act(() => {
260+
fireEvent.scroll(scroller);
261+
vi.advanceTimersToNextFrame();
262+
});
263+
};
264+
const highlighted = () =>
265+
within(host.container.querySelector('[data-testid="form-section-nav"]') as HTMLElement)
266+
.getAllByRole('button')
267+
.find((b) => b.getAttribute('aria-current') === 'true')
268+
?.textContent;
269+
return { scrollTo, highlighted };
270+
}
271+
272+
beforeEach(() => {
273+
vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'requestAnimationFrame', 'cancelAnimationFrame'] });
274+
});
275+
afterEach(() => {
276+
vi.useRealTimers();
277+
});
278+
279+
it('follows a scroll back to the top that lands inside the click hold, once the hold ends', () => {
280+
const { scrollTo, highlighted } = mountFixture([0, 600, 1200, 1800], 2400);
281+
fireEvent.click(screen.getByTestId('form-section-nav:s2'));
282+
scrollTo(1200);
283+
expect(highlighted()).toBe('Section 2');
284+
285+
// The refused submit's scroll back to the first error, inside the hold.
286+
scrollTo(0);
287+
expect(highlighted()).toBe('Section 2');
288+
289+
act(() => {
290+
vi.advanceTimersByTime(800);
291+
vi.advanceTimersToNextFrame();
292+
});
293+
expect(highlighted()).toBe('Section 0');
294+
});
295+
296+
it('follows a scroll back to the top that comes after the hold', () => {
297+
const { scrollTo, highlighted } = mountFixture([0, 600, 1200, 1800], 2400);
298+
fireEvent.click(screen.getByTestId('form-section-nav:s2'));
299+
scrollTo(1200);
300+
act(() => {
301+
vi.advanceTimersByTime(800);
302+
vi.advanceTimersToNextFrame();
303+
});
304+
expect(highlighted()).toBe('Section 2');
305+
306+
scrollTo(0);
307+
expect(highlighted()).toBe('Section 0');
308+
});
309+
310+
it('CONTROL: the jump a click starts does not move the highlight through the sections it passes', () => {
311+
const { scrollTo, highlighted } = mountFixture([0, 600, 1200, 1800], 2400);
312+
fireEvent.click(screen.getByTestId('form-section-nav:s2'));
313+
const seen: Array<string | undefined> = [highlighted()];
314+
for (const top of [150, 450, 700, 950, 1200]) {
315+
scrollTo(top);
316+
seen.push(highlighted());
317+
}
318+
act(() => {
319+
vi.advanceTimersByTime(800);
320+
vi.advanceTimersToNextFrame();
321+
});
322+
seen.push(highlighted());
323+
expect(new Set(seen)).toEqual(new Set(['Section 2']));
324+
});
325+
326+
it('CONTROL: at the bottom of a short tail, the section the click picked keeps the highlight when the hold ends', () => {
327+
// Content 1900 high in a 600 box: the deepest scroll is 1300, where the
328+
// third heading (1350) sits in view below the top edge, the fourth too.
329+
const { scrollTo, highlighted } = mountFixture([0, 600, 1350, 1700], 1900);
330+
fireEvent.click(screen.getByTestId('form-section-nav:s2'));
331+
scrollTo(1300);
332+
act(() => {
333+
vi.advanceTimersByTime(800);
334+
vi.advanceTimersToNextFrame();
335+
});
336+
expect(highlighted()).toBe('Section 2');
337+
338+
// Scrolled there by hand, the bottom still reads as the last section.
339+
scrollTo(400);
340+
expect(highlighted()).toBe('Section 0');
341+
scrollTo(1300);
342+
expect(highlighted()).toBe('Section 3');
343+
});
344+
});

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ const SCROLL_SPY_OFFSET = 24;
3838

3939
/**
4040
* After a click, the jump's own scroll events must not move the highlight
41-
* through the sections it passes on the way.
41+
* through the sections it passes on the way. When the hold ends the highlight
42+
* is measured once more, so a scroll that landed inside the hold — a refused
43+
* submit taking the form back to its first error — is followed too.
4244
*/
4345
const CLICK_HOLD_MS = 800;
4446

@@ -74,15 +76,21 @@ export function FormSectionNav({ items, className }: FormSectionNavProps) {
7476
const [current, setCurrent] = React.useState<string | undefined>(undefined);
7577
// While set, the jump a click started is under way: see CLICK_HOLD_MS.
7678
const holding = React.useRef<ReturnType<typeof setTimeout> | null>(null);
79+
// The section the last click jumped to, while the form stays at its bottom:
80+
// a short tail shows several headings at once and the click picks one.
81+
const jumpedTo = React.useRef<string | null>(null);
82+
// Re-reads the scroll position; bound by the scroll spy below.
83+
const remeasure = React.useRef<(() => void) | null>(null);
7784
React.useEffect(() => () => {
7885
if (holding.current) clearTimeout(holding.current);
7986
}, []);
8087
const shown = items && items.length >= 2 ? items : null;
8188
const anchorIds = shown ? shown.map((i) => i.anchorId).join('\n') : '';
8289

8390
// Scroll spy: the current section is the last heading at or above the
84-
// scroller's top edge; at the very bottom it is the last section, whose
85-
// heading may never reach the top on a short tail.
91+
// scroller's top edge; at the very bottom it is the section a click jumped
92+
// to when its heading is in view, else the last section, whose heading may
93+
// never reach the top on a short tail.
8694
React.useEffect(() => {
8795
if (!anchorIds) return;
8896
const ids = anchorIds.split('\n');
@@ -101,8 +109,12 @@ export function FormSectionNav({ items, className }: FormSectionNavProps) {
101109
: window.scrollY > 0 && window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 2;
102110
let found = ids[0];
103111
if (atBottom) {
104-
found = ids[ids.length - 1];
112+
const clicked = jumpedTo.current ? document.getElementById(jumpedTo.current) : null;
113+
const viewBottom = scroller ? scroller.getBoundingClientRect().bottom : window.innerHeight;
114+
const clickedTop = clicked ? clicked.getBoundingClientRect().top : NaN;
115+
found = clickedTop >= top && clickedTop < viewBottom ? jumpedTo.current! : ids[ids.length - 1];
105116
} else {
117+
jumpedTo.current = null;
106118
for (const id of ids) {
107119
const el = document.getElementById(id);
108120
if (el && el.getBoundingClientRect().top - top <= SCROLL_SPY_OFFSET) found = id;
@@ -113,8 +125,10 @@ export function FormSectionNav({ items, className }: FormSectionNavProps) {
113125
const onScroll = () => {
114126
if (!frame) frame = requestAnimationFrame(measure);
115127
};
128+
remeasure.current = onScroll;
116129
target.addEventListener('scroll', onScroll, { passive: true });
117130
return () => {
131+
remeasure.current = null;
118132
target.removeEventListener('scroll', onScroll);
119133
if (frame) cancelAnimationFrame(frame);
120134
};
@@ -145,7 +159,9 @@ export function FormSectionNav({ items, className }: FormSectionNavProps) {
145159
if (holding.current) clearTimeout(holding.current);
146160
holding.current = setTimeout(() => {
147161
holding.current = null;
162+
remeasure.current?.();
148163
}, CLICK_HOLD_MS);
164+
jumpedTo.current = item.anchorId;
149165
setCurrent(item.key);
150166
const reveal = () =>
151167
document.getElementById(item.anchorId)?.scrollIntoView?.({ block: 'start', behavior: 'smooth' });

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

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import { ObjectForm } from './ObjectForm';
4949
import { applyColumnPermissions } from './fieldWriteGate';
5050
import { useUploadGate, UploadGateProvider, UploadInFlightNotice } from './uploadGate';
5151
import { FormDirtyReportContext } from './formDirtyReport';
52+
import { MasterDetailFrameContext } from './masterDetailFrame';
5253
import { useFormChromeTranslation } from './formChrome';
5354
import {
5455
buildMasterDetailBatch,
@@ -1780,6 +1781,9 @@ export const MasterDetailForm: React.FC<MasterDetailFormProps> = ({
17801781
* advances or empties the lines, so a saved document reads as pristine.
17811782
*/
17821783
const reportUnsaved = useContext(FormDirtyReportContext);
1784+
// A host frame of fixed height (the record dialog, objectstack#34819): the
1785+
// body scrolls in its own box and the bar sits below it. See `masterDetailFrame`.
1786+
const frame = useContext(MasterDetailFrameContext);
17831787
const [headerDirty, setHeaderDirty] = useState(false);
17841788
const [rowEditorDirty, setRowEditorDirty] = useState(false);
17851789
const linesDirty = useMemo(
@@ -2179,9 +2183,8 @@ export const MasterDetailForm: React.FC<MasterDetailFormProps> = ({
21792183

21802184
useEffect(() => () => { if (saveGuardTimer.current) clearTimeout(saveGuardTimer.current); }, []);
21812185

2182-
return (
2183-
<UploadGateProvider gate={uploadGate}>
2184-
<div className={cn('space-y-6', className, schema.className)}>
2186+
const body = (
2187+
<>
21852188
{/* 1) Header fields on top */}
21862189
<div ref={formHostRef}>
21872190
<FormDirtyReportContext.Provider value={setHeaderDirty}>
@@ -2270,6 +2273,19 @@ export const MasterDetailForm: React.FC<MasterDetailFormProps> = ({
22702273
</CardContent>
22712274
</Card>
22722275
)}
2276+
</>
2277+
);
2278+
2279+
return (
2280+
<UploadGateProvider gate={uploadGate}>
2281+
<div className={cn(frame ? 'flex min-h-0 flex-1 flex-col' : 'space-y-6', className, schema.className)}>
2282+
{frame ? (
2283+
<div className={cn('min-h-0 flex-1 overflow-y-auto space-y-6', frame.bodyClassName)} data-testid="md-form-body">
2284+
{body}
2285+
</div>
2286+
) : (
2287+
body
2288+
)}
22732289

22742290
{/* Single action bar at the bottom — suppressed when the host opts out
22752291
(e.g. the Studio screen-preview, which must never persist).
@@ -2281,10 +2297,19 @@ export const MasterDetailForm: React.FC<MasterDetailFormProps> = ({
22812297
scroller may set `overflow`. Sticky stops at the scroller's CONTENT
22822298
edge: the `after:` strip paints over the host's bottom padding below
22832299
it, so lines never scroll through that gap. Owned here, not by the
2284-
host (ADR-0035 Decision §6: the form owns its Save). */}
2300+
host (ADR-0035 Decision §6: the form owns its Save).
2301+
In a host frame of fixed height (objectstack#34819) the bar is not
2302+
sticky: it is the flex row below the body's own scroller, outside
2303+
the scrolled content, so nothing the body holds can lift it off the
2304+
frame's bottom edge. */}
22852305
{schema.showSubmit !== false && (
22862306
<div
2287-
className="sticky bottom-0 z-10 border-t border-border bg-background pt-4 pb-3 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-6 after:bg-background"
2307+
className={cn(
2308+
'border-t border-border bg-background',
2309+
frame
2310+
? cn('shrink-0', frame.actionsClassName)
2311+
: 'sticky bottom-0 z-10 pt-4 pb-3 after:pointer-events-none after:absolute after:inset-x-0 after:top-full after:h-6 after:bg-background',
2312+
)}
22882313
data-testid="md-form-actions"
22892314
>
22902315
{/* Why Save is unavailable — above the row so it reads before the

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
} from '@object-ui/components';
4040
import { Loader2, Maximize2, Minimize2 } from 'lucide-react';
4141
import { MasterDetailForm } from './MasterDetailForm';
42+
import { MasterDetailFrameContext, type MasterDetailFrame } from './masterDetailFrame';
4243
import { SchemaRenderer, useSafeFieldLabel, usePreviewMode } from '@object-ui/react';
4344
import { createSafeTranslation, useLocalization } from '@object-ui/i18n';
4445
import { buildSectionFields as buildSectionFieldsShared } from './sectionFields';
@@ -1296,8 +1297,13 @@ const ModalFormBody: React.FC<ModalFormProps> = ({
12961297
);
12971298

12981299
if (subforms?.length && schema.mode !== 'view') {
1299-
// The master-detail form owns its Save bar and pins it to the bottom of
1300-
// the body scroller below (objectstack#34599); it reports its unsaved
1300+
// The master-detail form owns its Save bar (objectstack#34599, ADR-0035
1301+
// Decision §6). This dialog hands it a frame of fixed height — the region
1302+
// between the header and the dialog's bottom — through
1303+
// `MasterDetailFrameContext`, so the form scrolls its body in a box of its
1304+
// own and draws the bar below it, at the dialog's bottom at every scroll
1305+
// position, with the gutters the flat arm's body and footer use
1306+
// (objectstack#34819). It reports its unsaved
13011307
// input — header, lines, row editor — into this dialog's close guard, so
13021308
// the close paths prompt here exactly as they do in the flat arm. Its
13031309
// batch save carries no OCC token, so this arm has no conflict dialog.
@@ -1320,8 +1326,9 @@ const ModalFormBody: React.FC<ModalFormProps> = ({
13201326
)}
13211327
</DialogHeader>
13221328
)}
1323-
<div className="@container flex-1 overflow-y-auto px-4 sm:px-6 py-4">
1324-
<Suspense fallback={<ModalFormBodyPending />}>
1329+
<div className="flex min-h-0 flex-1 flex-col" data-testid="modal-form-md-frame">
1330+
<Suspense fallback={<div className="px-4 sm:px-6 py-4"><ModalFormBodyPending /></div>}>
1331+
<MasterDetailFrameContext.Provider value={MODAL_MASTER_DETAIL_FRAME}>
13251332
<FormDirtyReportContext.Provider value={setIsDirty}>
13261333
<MasterDetailForm
13271334
schema={{
@@ -1359,6 +1366,7 @@ const ModalFormBody: React.FC<ModalFormProps> = ({
13591366
dataSource={dataSource}
13601367
/>
13611368
</FormDirtyReportContext.Provider>
1369+
</MasterDetailFrameContext.Provider>
13621370
</Suspense>
13631371
</div>
13641372
{discardDialog}
@@ -1467,6 +1475,16 @@ const ModalFormBody: React.FC<ModalFormProps> = ({
14671475
);
14681476
};
14691477

1478+
/**
1479+
* The frame the master-detail arm hands its form (objectstack#34819): the
1480+
* body scroller takes the flat arm's body gutters and container query, the
1481+
* action bar the flat arm's footer padding.
1482+
*/
1483+
const MODAL_MASTER_DETAIL_FRAME: MasterDetailFrame = {
1484+
bodyClassName: '@container px-4 sm:px-6 py-4',
1485+
actionsClassName: 'px-4 sm:px-6 py-3',
1486+
};
1487+
14701488
/**
14711489
* What the dialog's body shows while a field widget's code loads
14721490
* (objectui#12559).

0 commit comments

Comments
 (0)