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( @@ -80,7 +85,9 @@ describe('edge sheets are not rounded by the dialog corner rule (#35411)', () => , ); - 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`] = `