Skip to content

Commit ea132c4

Browse files
committed
test(plugin-form): pin the form dialog's maximize switch in both arms
Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-authored-by: Claude <noreply@anthropic.com>
1 parent cf656b2 commit ea132c4

2 files changed

Lines changed: 33 additions & 3 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): the form dialog's header has a maximize / restore button, like the record drawer's, and remembers the choice per object
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
A create or edit dialog could not be made bigger: a long form, or a form with line items, stayed in a dialog capped at 90% of the window height. The dialog header now has the record drawer's maximize button (the same icon, size and labels, "Maximize" / "Restore size"), just before the close (X) button.
11+
12+
- **Maximize** widens the dialog to the `full` size (95% of the window width) and makes it fill 95% of the window height. The form body scrolls inside the dialog.
13+
- **Restore size** puts the dialog back to its declared or inferred size.
14+
- The form stays open the whole time. Typed values, the unsaved-changes prompt on close, and line items added in a form with `subforms` are all kept.
15+
- Both dialog kinds have the button: a plain form and a form with `subforms` (line items).
16+
- A maximized dialog with no declared `columns` uses the `full` column count, so a form with sixteen or more fields shows four per row.
17+
- The choice is remembered per object in the browser's local storage. The next dialog for that object opens the same way. Other objects are not affected.
18+
- On a phone the dialog already fills the screen, so the button is shown from the `sm` breakpoint up only.
19+
20+
No metadata changes. An authored `modalSize` is still the size the dialog opens with until the user maximizes it.

‎ui/packages/plugin-form/src/__tests__/modalMaximize-34604.test.tsx‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ describe('#34604 — the master-detail (subforms) arm', () => {
298298
}
299299

300300
const qtyInputs = () => screen.queryAllByLabelText('Qty') as HTMLInputElement[];
301+
/** The same input ELEMENTS, in order — identity, not structural equality. */
302+
const expectSameLines = (lines: HTMLInputElement[]) => {
303+
const now = qtyInputs();
304+
expect(now.length).toBe(lines.length);
305+
now.forEach((el, i) => expect(el).toBe(lines[i]));
306+
};
301307

302308
it('draws the switch and toggles the same content node in place', async () => {
303309
renderMd();
@@ -321,15 +327,19 @@ describe('#34604 — the master-detail (subforms) arm', () => {
321327
const before = qtyInputs().length;
322328
fireEvent.click(screen.getByRole('button', { name: /add/i }));
323329
await waitFor(() => expect(qtyInputs().length).toBe(before + 1));
324-
const line = qtyInputs()[before];
330+
// Type into the first line, so the grid's own trailing-row behaviour on
331+
// its last line stays out of the count.
332+
const lines = qtyInputs();
333+
const line = lines[0];
325334
fireEvent.change(line, { target: { value: '7' } });
335+
expectSameLines(lines);
326336

327337
fireEvent.click(maximizeButton());
328338
fireEvent.click(maximizeButton());
329339
fireEvent.click(maximizeButton());
330340
expectMaximized(dialog());
331-
expect(qtyInputs().length).toBe(before + 1);
332-
expect(qtyInputs()[before]).toBe(line);
341+
// The same line inputs, element for element: nothing below remounted.
342+
expectSameLines(lines);
333343
expect(line.value).toBe('7');
334344
expect(await headerInput()).toBe(title);
335345
expect(title.value).toBe('Q-1');

0 commit comments

Comments
 (0)