diff --git a/.changeset/35980-dialog-surface.md b/.changeset/35980-dialog-surface.md
new file mode 100644
index 00000000000..24585a96775
--- /dev/null
+++ b/.changeset/35980-dialog-surface.md
@@ -0,0 +1,28 @@
+---
+'@object-ui/components': patch
+'@object-ui/plugin-form': patch
+'@object-ui/i18n': patch
+'@object-ui/app-shell': patch
+'@object-ui/console': patch
+---
+
+feat(ui): every modal dialog draws one lighter surface, short create and edit dialogs are one narrow column, and a create dialog can stay open for the next record
+
+Clause-②: yes (widening)
+Metadata-protocol: none
+
+What a user sees:
+
+- Behind a dialog the page is only slightly dimmed (10% in light mode) and no longer blurred, so it stays readable. The dialog is a white card (the raised grey in dark mode) with a hairline edge and a translucent outer ring, a 12px corner, and anything inside it drawn at the shared 40px control height (`h-10`: inputs, select triggers, default and icon buttons, and any other `h-10` element such as a 40px avatar) one step smaller, 32px from the `sm` breakpoint up; the phone sheet keeps its 44px touch targets. Confirmation dialogs, the required-fields prompt and the record create and edit dialog all share it.
+- The create and edit dialog's title is 16px and follows the object's icon, and its padding is 20px.
+- A dialog that lays out at most six fields and declares no `columns` (not on the form, not on any section) draws one field per row in the narrow `lg` size (672px); six is the maintainer's choice (ruling of record 7061696632 on objectstack-ai/objectstack#35980). This reverses the at-least-two-columns default such a dialog drew before. Seven fields or more, any declared `columns`, an authored `modalSize` or a maximized dialog lay out as before.
+- The console's list 「New」 dialog (and a related list's child create) has a 「Create more」 switch. With it on, a save keeps the dialog open on an empty form with focus on the first field, and the list behind refreshes; with it off, a save closes the dialog and opens the new record as before. The switch is remembered per object in this browser.
+- ⌘↵ (Ctrl+Enter on other platforms) saves the create and edit dialog, and the Save button shows the keycaps. A master-detail dialog (a record with line items) takes neither the shortcut nor 「Create more」.
+
+What a developer sees (`Clause-②: yes (widening)`, additions only):
+
+- `ModalFormSchema.createMore?: boolean` offers the switch on a `create` dialog that a host mounts itself (the `object-form` renderer's `formType: 'modal'` keeps it off), and `ModalFormSchema.onSuccess` receives a second argument, `{ createMore: true }`, when the dialog stays open. A host that passes neither sees no change.
+- New i18n key `form.createMore` in every locale.
+- The console's global `[role="dialog"]` corner rule and the blurred overlay on dialogs are gone; the look lives in `@object-ui/components` (`src/lib/dialog-surface.ts`), reached from the `dialog` and `alert-dialog` primitives through declared Shadcn patches. The card carries the `dialog-surface` class, which the console's shared floating-surface shadow skips; a host stylesheet that adds its own shadow to `[role="dialog"]` should skip it too. Popovers and the bottom drawer keep their rounded corners by their own containers; side drawers are unchanged.
+
+Nothing to migrate.
diff --git a/ui/apps/console/src/__tests__/edgeSheetSquareCorners-35411.test.tsx b/ui/apps/console/src/__tests__/edgeSheetSquareCorners-35411.test.tsx
index 421a7d2f33c..93b6726348e 100644
--- a/ui/apps/console/src/__tests__/edgeSheetSquareCorners-35411.test.tsx
+++ b/ui/apps/console/src/__tests__/edgeSheetSquareCorners-35411.test.tsx
@@ -1,12 +1,16 @@
/**
- * The console's extra-rounded dialog corners skip full-height edge drawers
- * (objectstack#35411).
+ * The console's extra-rounded corners skip full-height edge drawers
+ * (objectstack#35411) and, since objectstack#35980, every modal dialog.
*
- * `index.css` gives every `role="dialog"` surface a 1.25rem radius. A left or
- * right Sheet is fixed against the top, side and bottom of the viewport, so the
- * radius showed as a notch at each inner corner. The rule now skips the Sheet's
- * edge variants by the `inset-y-0` class their variant carries, while centred
- * dialogs and bottom sheets keep the radius.
+ * `index.css` used to give every `role="dialog"` surface a 1.25rem radius. A
+ * left or right Sheet is fixed against the top, side and bottom of the
+ * viewport, so the radius showed as a notch at each inner corner; #35411 made
+ * the rule skip the Sheet's edge variants. #35980 moved the dialog's look onto
+ * the dialog itself (`dialog-surface`, a 12px card), so the rule no longer
+ * names every `role="dialog"`: it keeps the rounded corners for the floating
+ * popover and the bottom drawer only, by their own containers. A top or
+ * bottom Sheet meets the viewport on three edges like a side one, and is no
+ * longer matched either.
*
* The record drawer is the exception: it is a floating card (objectstack#35854)
* that sets its own radius, so the global rule must not override it either.
@@ -59,20 +63,21 @@ function renderSheet(side: 'left' | 'right' | 'bottom' | 'top'): HTMLElement {
return screen.getByRole('dialog');
}
-describe('edge sheets are not rounded by the dialog corner rule (#35411)', () => {
- it('the rule still targets dialogs', () => {
- expect(roundingSelector()).toContain('[role="dialog"]');
+describe('edge sheets and dialogs are not rounded by the corner rule (#35411, #35980)', () => {
+ it('the rule names popovers and the bottom drawer, never every dialog', () => {
+ const selector = roundingSelector();
+ expect(selector).toContain('[data-radix-popper-content-wrapper] > [role="dialog"]');
+ expect(selector).toContain('[data-vaul-drawer]');
+ for (const part of selector.split(',')) {
+ expect(part.trim().startsWith('[role="dialog"]')).toBe(false);
+ }
});
- it.each(['left', 'right'] as const)('a %s sheet is not matched', (side) => {
+ it.each(['left', 'right', 'bottom', 'top'] as const)('a %s sheet is not matched', (side) => {
expect(renderSheet(side).matches(roundingSelector())).toBe(false);
});
- it.each(['bottom', 'top'] as const)('a %s sheet keeps the rounded corners', (side) => {
- expect(renderSheet(side).matches(roundingSelector())).toBe(true);
- });
-
- it('a centred dialog keeps the rounded corners', () => {
+ it('a centred dialog is not matched: it carries its own corner', () => {
render(
,
);
- expect(screen.getByRole('dialog').matches(roundingSelector())).toBe(true);
+ const dialog = screen.getByRole('dialog');
+ expect(dialog.matches(roundingSelector())).toBe(false);
+ expect(dialog.className.split(/\s+/)).toContain('sm:rounded-[12px]');
});
});
diff --git a/ui/apps/console/src/index.css b/ui/apps/console/src/index.css
index 303259ad430..8172bd07a48 100644
--- a/ui/apps/console/src/index.css
+++ b/ui/apps/console/src/index.css
@@ -448,8 +448,10 @@ header.sticky {
background-color: hsl(var(--background) / 0.6) !important;
}
-/* Soft, diffuse iOS elevation on floating surfaces (dialogs, menus, popovers). */
-[role="dialog"],
+/* Soft, diffuse iOS elevation on floating surfaces (drawers, menus, popovers).
+ A modal dialog draws its own two-layer card (`dialog-surface`,
+ `packages/components/src/lib/dialog-surface.ts`) and is skipped here. */
+[role="dialog"]:not(.dialog-surface),
[role="menu"],
[data-radix-popper-content-wrapper] > * {
box-shadow:
@@ -513,11 +515,14 @@ header.sticky {
background-color: hsl(135 59% 49%) !important;
}
-/* iOS sheet/dialog: extra-rounded corners, for surfaces that float or rise from
- the bottom. A full-height edge drawer (the left/right Sheet, whose variant
- pins it with `inset-y-0`) meets the viewport on three edges, so it keeps
- square corners. */
-[role="dialog"]:not(.inset-y-0) {
+/* iOS popover / bottom drawer: extra-rounded corners on the surfaces that float
+ beside a control or rise from the bottom. Keyed on their own containers —
+ a popover inside the floating layer's wrapper, the bottom drawer by its own
+ attribute — and no longer on every `[role="dialog"]`: a modal dialog carries
+ its own corner (`dialog-surface`), and a full-height edge drawer meets the
+ viewport on three edges, so it keeps square corners. */
+[data-radix-popper-content-wrapper] > [role="dialog"],
+[data-vaul-drawer] {
border-radius: 1.25rem !important;
}
@@ -551,8 +556,10 @@ header.sticky {
* (CSS-only overrides; shadcn ui components not edited)
* ------------------------------------------------------------ */
-/* iOS "spotlight"-style backdrop: blur + lighten the dim behind any
- dialog / sheet / command palette overlay instead of a flat 80% black. */
+/* iOS "spotlight"-style backdrop for drawers: blur + lighten the dim behind a
+ sheet or a bottom drawer instead of a flat 80% black. A modal dialog's
+ overlay no longer carries `bg-black/80` (its faint, unblurred dim is
+ `DIALOG_OVERLAY_SURFACE`), so this rule reaches drawers only. */
.fixed.inset-0.z-50.bg-black\/80 {
background-color: rgb(0 0 0 / 0.35) !important;
-webkit-backdrop-filter: blur(8px) saturate(140%);
diff --git a/ui/packages/app-shell/src/console/AppContent.tsx b/ui/packages/app-shell/src/console/AppContent.tsx
index 9e115400ed1..f8b4f11560a 100644
--- a/ui/packages/app-shell/src/console/AppContent.tsx
+++ b/ui/packages/app-shell/src/console/AppContent.tsx
@@ -1070,13 +1070,22 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
// the drawer over the still-intact list; a heavy one is the detail route.
// `replace: true` swaps out the transient `?form=…` entry so Back returns
// to the pre-create origin.
- const handleRecordFormSuccess = useCallback(async (saved: any) => {
+ const handleRecordFormSuccess = useCallback(async (saved: any, outcome?: { createMore?: boolean }) => {
// Child task (objectstack-ai/objectstack#2604 D3): the parent detail must stay EXACTLY as it was —
// active tab, scroll, everything. So do NOT go through crud_success;
// the child's open related lists refetch on their own via the
// invalidation bus (#2269): the dataSource write already emitted a
// MutationEvent that the bridge fans out — no manual notify needed.
const feedback = answerWarningClaim.current?.take(saved);
+ // 「Create more」 (objectstack-ai/objectstack#35980): the dialog stays open
+ // on an empty form for the next record. Say the save landed and refresh
+ // the list behind (a child task's related lists refetch on the bus), but
+ // neither close the form nor leave for the new record.
+ if (outcome?.createMore) {
+ toastRecordSave(toast, recordSaveMessage(saved), feedback);
+ if (!isChildFormTask) setRefreshKey(k => k + 1);
+ return;
+ }
if (isChildFormTask) {
toastRecordSave(toast, recordSaveMessage(saved), feedback);
closeRecordForm();
@@ -1758,6 +1767,11 @@ export function AppContent({ extraRoutes, extraRoutesNoApp }: AppContentProps =
: [],
onSuccess: handleRecordFormSuccess,
onCancel: handleDialogCancel,
+ // The footer's 「Create more」 switch on a create, for the
+ // list's 「New」 and a related list's child create alike
+ // (objectstack-ai/objectstack#35980). ModalForm shows it on a
+ // create only.
+ createMore: true,
// objectstack-ai/objectstack#26843 — the selected form view's
// `buttons`, `layout` and `defaults` over this dialog's own
// defaults (`resolveFormViewChrome` states the precedence). A
diff --git a/ui/packages/app-shell/src/console/__tests__/AppContent.createLandingOriginPlural-11733.test.tsx b/ui/packages/app-shell/src/console/__tests__/AppContent.createLandingOriginPlural-11733.test.tsx
index 8d12ccc8736..632442b4995 100644
--- a/ui/packages/app-shell/src/console/__tests__/AppContent.createLandingOriginPlural-11733.test.tsx
+++ b/ui/packages/app-shell/src/console/__tests__/AppContent.createLandingOriginPlural-11733.test.tsx
@@ -38,12 +38,18 @@ import React from 'react';
import { render, cleanup, waitFor, screen } from '@testing-library/react';
import { MemoryRouter, Routes, Route } from 'react-router-dom';
import { createI18n, I18nProvider } from '@object-ui/i18n';
+// AppContent reaches the console's dynamic `@objectstack/lint` imports; their
+// first load is paid here, at collection, never inside a case's clock
+// (`check:test-source-alias`).
+import '@objectstack/lint';
import { RECORD_SURFACE_PAGE_THRESHOLD } from '@object-ui/plugin-view';
/** The part of the modal's schema this file reads. */
interface ModalSchemaProbe {
objectName?: string;
- onSuccess: (saved: { id: string }) => Promise | void;
+ open?: boolean;
+ createMore?: boolean;
+ onSuccess: (saved: { id: string }, outcome?: { createMore?: boolean }) => Promise | void;
}
const { modalSchemas } = vi.hoisted(() => ({ modalSchemas: [] as ModalSchemaProbe[] }));
@@ -205,3 +211,33 @@ describe('AppContent — a create that lands on the record page names the way ba
expect(await originAfterCreate('en', 'showcase_note')).toBe('Note');
});
});
+
+// objectstack-ai/objectstack#35980 — with 「Create more」 on, the dialog stays
+// for the next record: the console neither closes the form nor leaves for
+// the record it just made.
+describe('AppContent — a 「Create more」 save stays on the list (objectstack-ai/objectstack#35980)', () => {
+ it('offers the switch, and a save told to stay does not land on the record page', async () => {
+ session.lang = 'en';
+ const i18n = createI18n({ defaultLanguage: 'en', detectBrowserLanguage: false });
+ render(
+
+
+
+ } />
+
+
+ ,
+ );
+ await waitFor(() => expect(modalSchemas.length).toBeGreaterThan(0));
+ const schema = modalSchemas[modalSchemas.length - 1];
+ expect(schema.createMore).toBe(true);
+
+ await schema.onSuccess({ id: 'r9' }, { createMore: true });
+ await new Promise((r) => setTimeout(r, 300));
+ expect(screen.queryByTestId('origin-label')).toBeNull();
+ // The form is still the open dialog on the list's route.
+ const latest = modalSchemas[modalSchemas.length - 1];
+ expect(latest.open).toBe(true);
+ expect(latest.objectName).toBe('showcase_project');
+ });
+});
diff --git a/ui/packages/components/shadcn-components.json b/ui/packages/components/shadcn-components.json
index 99ae663eba4..35ecb764fad 100644
--- a/ui/packages/components/shadcn-components.json
+++ b/ui/packages/components/shadcn-components.json
@@ -34,7 +34,8 @@
],
"registryDependencies": [
"button"
- ]
+ ],
+ "localEdits": "objectstack#35980 shared dialog surface: the overlay and the content each append one class token (`DIALOG_OVERLAY_SURFACE` / `DIALOG_CONTENT_SURFACE`, `packages/components/src/lib/dialog-surface.ts`), so a confirmation draws the same faint overlay and white two-layer card as every other dialog. Declared as data in `scripts/shadcn-local-patches.mjs` and re-applied on every `--update`; the vendored registry fixture regenerates the file byte for byte (`roundTrip: true`)."
},
"aspect-ratio": {
"source": "https://ui.shadcn.com/r/styles/default/aspect-ratio.json",
@@ -131,7 +132,7 @@
"radix-ui"
],
"registryDependencies": [],
- "localEdits": "objectstack#5505 i18n close patch: `DialogContent` auto-renders an icon-only close button whose `sr-only` span IS its accessible name, and upstream hardcodes the English literal — so under zh/ja/es every modal in the console announced \"Close\" in English. The span is replaced by `` (`packages/components/src/lib/close-label.tsx`), which resolves `common.close` for the session locale and falls back to English with no I18nProvider mounted. It also carries the objectstack#29107 phone close touch-target patch: below `sm` the close button is a 44 px box with the 16 px glyph centred, and from `sm` up its classes are upstream's. Both edits are DECLARED as data in `scripts/shadcn-local-patches.mjs` and re-applied on every `--update`, and `pnpm shadcn:check` exits non-zero if either is ever missing from the file or can no longer be re-applied to upstream."
+ "localEdits": "objectstack#5505 i18n close patch: `DialogContent` auto-renders an icon-only close button whose `sr-only` span IS its accessible name, and upstream hardcodes the English literal — so under zh/ja/es every modal in the console announced \"Close\" in English. The span is replaced by `` (`packages/components/src/lib/close-label.tsx`), which resolves `common.close` for the session locale and falls back to English with no I18nProvider mounted. It also carries the objectstack#29107 phone close touch-target patch: below `sm` the close button is a 44 px box with the 16 px glyph centred, and from `sm` up its classes are upstream's. Both edits are DECLARED as data in `scripts/shadcn-local-patches.mjs` and re-applied on every `--update`, and `pnpm shadcn:check` exits non-zero if either is ever missing from the file or can no longer be re-applied to upstream. objectstack#35980 adds the shared dialog surface: one import and one class token each on the overlay and the content, naming `DIALOG_OVERLAY_SURFACE` / `DIALOG_CONTENT_SURFACE` (`packages/components/src/lib/dialog-surface.ts`), declared in the same file."
},
"drawer": {
"source": "https://ui.shadcn.com/r/styles/default/drawer.json",
diff --git a/ui/packages/components/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap b/ui/packages/components/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap
index 2a1d09ad828..34887b904ee 100644
--- a/ui/packages/components/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap
+++ b/ui/packages/components/src/__tests__/__snapshots__/snapshot-critical.test.tsx.snap
@@ -448,7 +448,7 @@ exports[`Dialog snapshots > renders open dialog structure 1`] = `
renders open dialog structure 1`] = `
expect(nav()).not.toBeNull());
// With the bar drawn, the bar is the separator under the header.
- expect(header().classList.contains('border-b')).toBe(false);
+ await waitFor(() => expect(header().classList.contains('border-b')).toBe(false));
sizeScroller(600, 420);
resized();
diff --git a/ui/packages/plugin-form/src/ModalForm.tsx b/ui/packages/plugin-form/src/ModalForm.tsx
index a670c018891..aace2f0b3a8 100644
--- a/ui/packages/plugin-form/src/ModalForm.tsx
+++ b/ui/packages/plugin-form/src/ModalForm.tsx
@@ -36,6 +36,8 @@ import {
RecordTopBarButton,
toast,
FormSectionNavContext,
+ Switch,
+ resolveIcon,
} from '@object-ui/components';
import { Loader2, Maximize2, Minimize2 } from 'lucide-react';
import { MasterDetailForm } from './MasterDetailForm';
@@ -53,6 +55,7 @@ import {
inferColumns,
inferModalSize,
dialogUndeclaredColumns,
+ dialogDrawsSingleColumn,
sectionedFormColumns,
sectionedGridLayout,
CONTAINER_GRID_COLS,
@@ -87,10 +90,11 @@ import {
import { hasInlineFieldSource, noSubmitTargetError } from './submitTarget';
import { useRecordInvalidation } from './recordInvalidation';
import { useUploadGate, UploadGateProvider, UploadInFlightNotice } from './uploadGate';
-import { useInitialFieldFocus } from './initialFieldFocus';
+import { focusFirstEditableField, useInitialFieldFocus } from './initialFieldFocus';
import { FormSectionNav, useFormSectionNav } from './FormSectionNav';
import { FormDirtyReportContext } from './formDirtyReport';
import { useModalFormMaximized } from './modalMaximize';
+import { isSubmitShortcut, submitShortcutLabel, useModalFormCreateMore } from './createMore';
// Localized strings for the unsaved-changes guard and, since objectui#11039,
// the form's own chrome (the default submit and cancel labels and the
@@ -125,6 +129,8 @@ const useDiscardTranslation = createSafeTranslation(
// keys and labels (objectstack-ai/objectstack#34604).
'detail.maximize': 'Maximize',
'detail.restoreSize': 'Restore size',
+ // The create dialog's 「Create more」 switch (objectstack-ai/objectstack#35980).
+ 'form.createMore': 'Create more',
},
'form.discardTitle',
);
@@ -266,9 +272,27 @@ export interface ModalFormSchema {
*/
submitHandler?: ObjectFormSchema['submitHandler'];
- onSuccess?: (data: any) => void | Promise;
+ /**
+ * Called with the saved record. `outcome.createMore` is `true` when the
+ * dialog stays open for the next record (the 「Create more」 switch,
+ * {@link ModalFormSchema.createMore}): the host refreshes what lists the
+ * record and stays where it is, instead of closing or leaving for the new
+ * record.
+ */
+ onSuccess?: (data: any, outcome?: { createMore?: boolean }) => void | Promise;
onError?: (error: Error) => void;
onCancel?: () => void;
+ /**
+ * Offer the 「Create more」 switch in a `create` dialog's footer
+ * (objectstack-ai/objectstack#35980). On, a successful save keeps the dialog
+ * open: the form is drawn again from its opening values, focus returns to
+ * the first field, and `onSuccess` is told so. The switch is remembered per
+ * object in this browser. Off by default: a host offers it where creating
+ * several records in a row makes sense (a list's 「New」), and not where the
+ * create returns a record to its caller (a lookup's inline 「+ New」).
+ * Ignored by the master-detail arm, whose form owns its own Save bar.
+ */
+ createMore?: boolean;
className?: string;
/** Inline child collections — renders the modal as an atomic master-detail
* form. Each entry needs only `childObject` (FK + columns derived). */
@@ -323,7 +347,9 @@ const modalSizeClasses: Record = {
/**
* The least grid the dialog draws where the author declared no `columns`
* (objectui#12521): two from the container's `@md` tier up, one below it, so
- * the phone sheet keeps its single column. A field-heavy form draws more —
+ * the phone sheet keeps its single column — except in a short dialog that
+ * declares nothing, which draws one column in the narrow `lg` size
+ * (`dialogDrawsSingleColumn`, objectstack-ai/objectstack#35980). A field-heavy form draws more —
* three in a bounded dialog, four in a `full` one — by
* `dialogUndeclaredColumns` (objectstack-ai/objectstack#34607), whose
* docblock carries the rule and the measured tier.
@@ -526,6 +552,15 @@ const ModalFormBody: React.FC = ({
// column count — reads that effective size.
const { maximized, toggleMaximized } = useModalFormMaximized(schema.objectName);
+ // The 「Create more」 switch (objectstack-ai/objectstack#35980): offered on
+ // a create dialog whose host asked for it, remembered per object. A save
+ // with it on draws the form again (`formResetKey`) instead of closing.
+ const createMoreOffered = schema.createMore === true && schema.mode === 'create';
+ const { createMore, setCreateMore } = useModalFormCreateMore(schema.objectName);
+ const createMoreOn = createMoreOffered && createMore;
+ const [formResetKey, setFormResetKey] = useState(0);
+ const contentRef = useRef(null);
+
// The dialog's size when the author declared none (objectui#12521): bounded
// — `lg` or `xl`, never `full` — and chosen from the declared grid and the
// field count, so a short form is not stretched across a wide dialog. An
@@ -533,19 +568,31 @@ const ModalFormBody: React.FC = ({
// undeclared grid is at least `DIALOG_DEFAULT_COLUMNS` wide whatever the
// size, so the size reads that floor and never the count it then bounds
// (objectstack-ai/objectstack#34607).
+ // objectstack-ai/objectstack#35980 — at most six fields (ruling 7061696632) and no declared
+ // `columns` anywhere: one per row, in the narrow `lg` dialog. Maximized,
+ // the user asked for the room, and the form spreads as it did before.
+ const singleColumn = !maximized && dialogDrawsSingleColumn(
+ layoutFieldCount,
+ schema.columns,
+ (effectiveSections ?? []).map((s) => s.columns),
+ );
const effectiveModalSize = useMemo(() => {
if (maximized) return 'full';
if (schema.modalSize) return schema.modalSize;
+ // A short dialog that declares no columns anywhere is one column in the
+ // narrow `lg` size (objectstack-ai/objectstack#35980).
+ if (singleColumn) return inferModalSize(1);
const columns = effectiveSections?.length
? sectionedFormColumns(schema.columns, effectiveSections.map((s) => s.columns), DIALOG_DEFAULT_COLUMNS)
: (clampColumns(schema.columns) ?? DIALOG_DEFAULT_COLUMNS);
return inferModalSize(Math.min(columns, inferColumns(layoutFieldCount)));
- }, [maximized, schema.modalSize, schema.columns, effectiveSections, layoutFieldCount]);
+ }, [maximized, schema.modalSize, schema.columns, effectiveSections, layoutFieldCount, singleColumn]);
// The count an undeclared form or section draws in THIS dialog
// (objectstack-ai/objectstack#34607): from the field count, bounded by the
- // dialog's size — `dialogUndeclaredColumns`.
- const undeclaredColumns = dialogUndeclaredColumns(layoutFieldCount, effectiveModalSize);
+ // dialog's size — `dialogUndeclaredColumns` — and one in a short dialog
+ // that declares nothing (`dialogDrawsSingleColumn`, #35980).
+ const undeclaredColumns = singleColumn ? 1 : dialogUndeclaredColumns(layoutFieldCount, effectiveModalSize);
// Compute auto-layout for flat fields (no sections). A form that declares no
// `columns` lays out at the dialog's undeclared count through the same
@@ -770,6 +817,29 @@ const ModalFormBody: React.FC = ({
endLoading();
}, [objectSchema, schema.fields, schema.customFields, schema.sections, schema.readOnly, schema.mode, dataSource]);
+ // 「Create more」 (objectstack-ai/objectstack#35980): after a save that keeps
+ // the dialog open, draw the form again from its opening values — a new
+ // `formResetKey` remounts the form renderer, so every typed value and the
+ // dirty state go with it — and put focus back on the first field.
+ const startNextRecord = useCallback(() => {
+ setIsDirty(false);
+ setFormResetKey((k) => k + 1);
+ }, []);
+ useEffect(() => {
+ if (formResetKey === 0) return;
+ // The remounted form draws its fields on a later frame (lazy widgets), so
+ // keep trying for a short while until the first field takes focus.
+ let tries = 0;
+ let frame = 0;
+ const attempt = () => {
+ const content = contentRef.current;
+ if (content && focusFirstEditableField(content)) return;
+ if (++tries < 30) frame = window.requestAnimationFrame(attempt);
+ };
+ frame = window.requestAnimationFrame(attempt);
+ return () => window.cancelAnimationFrame(frame);
+ }, [formResetKey]);
+
// Handle form submission
const handleSubmit = useCallback(async (data: Record) => {
// An upload is still in flight (objectui#10166). Saving now writes the
@@ -790,6 +860,11 @@ const ModalFormBody: React.FC = ({
// adapter-less submit, bypassing a declared host seam and persisting
// nothing (objectui#6300). See `submitTarget.ts` for the whole rule.
if (!dataSource && !schema.submitHandler && hasInlineFieldSource(schema)) {
+ if (createMoreOn) {
+ await schema.onSuccess?.(data, { createMore: true });
+ startNextRecord();
+ return data;
+ }
if (schema.onSuccess) {
await schema.onSuccess(data);
}
@@ -864,6 +939,13 @@ const ModalFormBody: React.FC = ({
// bus change held while it was dirty (its own write's echo included) is
// replayed now rather than behind input that is no longer unsaved.
recordSaved();
+ // 「Create more」 (objectstack-ai/objectstack#35980): the record is
+ // made, and the dialog stays for the next one.
+ if (createMoreOn) {
+ await schema.onSuccess?.(result, { createMore: true });
+ startNextRecord();
+ return result;
+ }
if (schema.onSuccess) {
await schema.onSuccess(result);
}
@@ -878,7 +960,7 @@ const ModalFormBody: React.FC = ({
} finally {
setIsSubmitting(false);
}
- }, [schema, dataSource, objectSchema, perms, saveWithOcc, formData, uploadGate.uploading, uploadGate.reason, recordSaved]);
+ }, [schema, dataSource, objectSchema, perms, saveWithOcc, formData, uploadGate.uploading, uploadGate.reason, recordSaved, createMoreOn, startNextRecord]);
// Actually close the modal, firing onCancel only when the close originated
// from the explicit Cancel button.
@@ -1269,7 +1351,43 @@ const ModalFormBody: React.FC = ({
// The header keeps its title clear of the switch and the X from `sm` up.
// Its bottom rule is each arm's: the flat arm hands it to the section nav
// strip when one is drawn.
- const headerClass = 'shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 sm:pr-20 pb-2';
+ const headerClass = 'shrink-0 px-4 pt-4 sm:px-5 sm:pr-20 pb-3';
+
+ // The title (objectstack-ai/objectstack#35980): 16px, after the object's
+ // own icon when it declares one, in both arms.
+ // `resolveIcon` caches one component per name, so this is no hook.
+ const ObjectIconGlyph = resolveIcon((objectSchema as any)?.icon);
+ const dialogTitle = schema.title ? (
+
+ {ObjectIconGlyph && (
+ // `resolveIcon` returns a STABLE component out of lucide's static
+ // record; it does not create one during render (the annotation the
+ // other seam call sites carry).
+ // eslint-disable-next-line react-hooks/static-components
+
+ )}
+ {schema.title}
+
+ ) : null;
+
+ // ⌘↵ / Ctrl+Enter saves (objectstack-ai/objectstack#35980), the shortcut the
+ // Save button shows. Only a keydown inside this dialog's own DOM: the
+ // discard and conflict alerts are React children, so their keydowns bubble
+ // here through React, but they are portalled outside the content.
+ const handleContentKeyDown = (event: React.KeyboardEvent) => {
+ if (!isSubmitShortcut({ ...event, isComposing: event.nativeEvent.isComposing })) return;
+ if (!event.currentTarget.contains(event.target as Node)) return;
+ if (!showSubmit || isSubmitting || uploadGate.uploading) return;
+ const form = event.currentTarget.ownerDocument.getElementById(formId);
+ if (!(form instanceof HTMLFormElement)) return;
+ event.preventDefault();
+ event.stopPropagation();
+ form.requestSubmit();
+ };
// Unsaved-changes guard — rendered INSIDE DialogContent so its portal
// inherits the Dialog's Radix layer context (focus scope + dismissable
@@ -1315,12 +1433,12 @@ const ModalFormBody: React.FC = ({
showCloseButton={showCloseButton}
onOpenAutoFocus={initialFieldFocus.onOpenAutoFocus}
onCloseAutoFocus={initialFieldFocus.onCloseAutoFocus}
- className={cn(sizeClass, 'flex flex-col overflow-hidden p-0', heightClass, className, schema.className)}
+ className={cn(sizeClass, 'flex flex-col overflow-hidden p-0 sm:p-0', heightClass, className, schema.className)}
data-maximized={maximized ? '' : undefined}
>
{(schema.title || schema.description) && (
- {schema.title && {schema.title}}
+ {dialogTitle}
{schema.description ? (
{schema.description}
) : (
@@ -1383,15 +1501,17 @@ const ModalFormBody: React.FC = ({
return (