Skip to content

Commit 2508113

Browse files
authored
Merge pull request #1010 from objectstack-ai/copilot/enhance-modal-form-layout
2 parents 124c005 + c1b292e commit 2508113

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

apps/console/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ export function AppContent() {
400400
description: editingRecord ? `Update details for ${currentObjectDef?.label}` : `Add a new ${currentObjectDef?.label} to your database.`,
401401
open: isDialogOpen,
402402
onOpenChange: setIsDialogOpen,
403-
modalSize: 'lg',
404403
layout: 'vertical',
405404
fields: currentObjectDef.fields
406405
? (Array.isArray(currentObjectDef.fields)

packages/plugin-form/src/ModalForm.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,19 @@ export interface ModalFormProps {
9696
className?: string;
9797
}
9898

99-
/** Size class map for the dialog content */
99+
/**
100+
* Size class map for the dialog content.
101+
*
102+
* Uses `sm:` prefix so that `tailwind-merge` correctly resolves the conflict
103+
* with MobileDialogContent's base `sm:max-w-lg` class. On mobile (< sm) the
104+
* dialog is already full-screen, so max-width only matters at sm+ breakpoints.
105+
*/
100106
const modalSizeClasses: Record<string, string> = {
101-
sm: 'max-w-sm',
102-
default: 'max-w-lg',
103-
lg: 'max-w-2xl',
104-
xl: 'max-w-4xl',
105-
full: 'max-w-[95vw] w-full',
107+
sm: 'sm:max-w-sm',
108+
default: 'sm:max-w-lg',
109+
lg: 'sm:max-w-2xl',
110+
xl: 'sm:max-w-5xl',
111+
full: 'sm:max-w-[95vw] sm:w-full',
106112
};
107113

108114
/**

packages/plugin-form/src/__tests__/MobileUX.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ describe('ModalForm Container Query Layout', () => {
323323
});
324324

325325
describe('ModalForm Sections — Modal Size Auto-Upgrade', () => {
326-
it('auto-upgrades modal to lg when sections use 2-column layout', async () => {
326+
it('auto-upgrades modal to xl when sections use 2-column layout', async () => {
327327
const mockDataSource = createMockDataSource();
328328

329329
render(
@@ -356,10 +356,10 @@ describe('ModalForm Sections — Modal Size Auto-Upgrade', () => {
356356
expect(screen.getByText('Create Task')).toBeInTheDocument();
357357
});
358358

359-
// Dialog should auto-upgrade to lg (max-w-2xl) because sections have columns: 2
359+
// Dialog should auto-upgrade to xl (max-w-5xl) because sections have columns: 2
360360
const dialogContent = document.querySelector('[role="dialog"]');
361361
expect(dialogContent).not.toBeNull();
362-
expect(dialogContent!.className).toContain('max-w-2xl');
362+
expect(dialogContent!.className).toContain('max-w-5xl');
363363
});
364364

365365
it('keeps default size when all sections use 1-column layout', async () => {

packages/plugin-form/src/__tests__/autoLayout.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,12 @@ describe('autoLayout', () => {
7676
expect(inferModalSize(1)).toBe('default');
7777
});
7878

79-
it('returns lg for 2 columns', () => {
80-
expect(inferModalSize(2)).toBe('lg');
79+
it('returns xl for 2 columns', () => {
80+
expect(inferModalSize(2)).toBe('xl');
8181
});
8282

83-
it('returns xl for 3 columns', () => {
84-
expect(inferModalSize(3)).toBe('xl');
85-
});
86-
87-
it('returns full for 4+ columns', () => {
83+
it('returns full for 3+ columns', () => {
84+
expect(inferModalSize(3)).toBe('full');
8885
expect(inferModalSize(4)).toBe('full');
8986
expect(inferModalSize(5)).toBe('full');
9087
});

packages/plugin-form/src/autoLayout.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,13 @@ export function filterCreateModeFields(
117117
* Used to auto-upgrade the modal width when auto-layout detects multi-column forms.
118118
*
119119
* Mapping:
120-
* - 1 column → 'default' (max-w-lg)
121-
* - 2 columns → 'lg' (max-w-2xl)
122-
* - 3 columns → 'xl' (max-w-4xl)
123-
* - 4+ columns → 'full' (max-w-[95vw])
120+
* - 1 column → 'default' (max-w-lg)
121+
* - 2 columns → 'xl' (max-w-5xl)
122+
* - 3+ columns → 'full' (max-w-[95vw])
124123
*/
125124
export function inferModalSize(columns: number): 'sm' | 'default' | 'lg' | 'xl' | 'full' {
126125
if (columns <= 1) return 'default';
127-
if (columns === 2) return 'lg';
128-
if (columns === 3) return 'xl';
126+
if (columns === 2) return 'xl';
129127
return 'full';
130128
}
131129

0 commit comments

Comments
 (0)