Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .changeset/35980-dialog-surface.md
Original file line number Diff line number Diff line change
@@ -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.
41 changes: 24 additions & 17 deletions ui/apps/console/src/__tests__/edgeSheetSquareCorners-35411.test.tsx
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -59,28 +63,31 @@ 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(
<Dialog open>
<DialogContent>
<DialogTitle>centred</DialogTitle>
</DialogContent>
</Dialog>,
);
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]');
});
});

Expand Down
25 changes: 16 additions & 9 deletions ui/apps/console/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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%);
Expand Down
16 changes: 15 additions & 1 deletion ui/packages/app-shell/src/console/AppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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> | void;
open?: boolean;
createMore?: boolean;
onSuccess: (saved: { id: string }, outcome?: { createMore?: boolean }) => Promise<void> | void;
}
const { modalSchemas } = vi.hoisted(() => ({ modalSchemas: [] as ModalSchemaProbe[] }));

Expand Down Expand Up @@ -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(
<I18nProvider instance={i18n}>
<MemoryRouter initialEntries={['/apps/crm/showcase_project?form=new']}>
<Routes>
<Route path="/apps/:appName/*" element={<AppContent />} />
</Routes>
</MemoryRouter>
</I18nProvider>,
);
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');
});
});
5 changes: 3 additions & 2 deletions ui/packages/components/shadcn-components.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 `<CloseSrLabel />` (`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 `<CloseSrLabel />` (`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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,15 +448,15 @@ exports[`Dialog snapshots > renders open dialog structure 1`] = `
</div>
<div
aria-hidden="true"
class="fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
class="fixed inset-0 z-50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 bg-black/10 dark:bg-black/40"
data-aria-hidden="true"
data-state="open"
style="pointer-events: auto;"
/>
<div
aria-describedby="radix-_r_2_"
aria-labelledby="radix-_r_1_"
class="fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg"
class="fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] dialog-surface bg-card text-card-foreground border-black/[0.07] dark:border-white/[0.09] sm:rounded-[12px] shadow-[0_0_0_3px_rgb(255_255_255/0.6),0_1px_2px_rgb(16_16_32/0.04),0_6px_16px_-4px_rgb(16_16_32/0.08),0_24px_48px_-12px_rgb(16_16_32/0.14)] dark:shadow-[0_0_0_3px_rgb(255_255_255/0.07),0_1px_2px_rgb(0_0_0/0.3),0_8px_24px_-6px_rgb(0_0_0/0.45),0_24px_48px_-12px_rgb(0_0_0/0.55)] sm:[&_.h-10]:h-8 sm:[&_.h-10]:py-1 sm:[&_.h-10.w-10]:w-8"
data-state="open"
id="radix-_r_0_"
role="dialog"
Expand Down
4 changes: 4 additions & 0 deletions ui/packages/components/src/custom/mobile-dialog-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { X } from 'lucide-react';
import { cn } from '../lib/utils';
import { CloseSrLabel } from '../lib/close-label';
import { DialogOverlay, DialogPortal } from '../ui/dialog';
import { DIALOG_CONTENT_SURFACE } from '../lib/dialog-surface';

/**
* Radix Select / Popover / DropdownMenu render their flyout into a portal at
Expand Down Expand Up @@ -142,6 +143,9 @@ export const MobileDialogContent = React.forwardRef<
'data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',
'data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]',
'data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]',
// The look every modal dialog shares (objectstack#35980): white card,
// hairline edge, outer ring, compact controls from `sm` up.
DIALOG_CONTENT_SURFACE,
className,
)}
{...props}
Expand Down
Loading
Loading