diff --git a/.changeset/36151-phone-bottom-bar-actions-only.md b/.changeset/36151-phone-bottom-bar-actions-only.md new file mode 100644 index 00000000000..964d176e163 --- /dev/null +++ b/.changeset/36151-phone-bottom-bar-actions-only.md @@ -0,0 +1,24 @@ +--- +'@objectstack/spec': minor +'@object-ui/components': minor +'@object-ui/app-shell': minor +--- + +feat(record-page): on a phone the record page's bottom bar holds the object's own actions only, and Edit moves into the More menu at the top bar's right end + +Clause-②: yes (widening) +Metadata-protocol: semantic + +On a phone the record page's bottom bar used to always draw Edit first, then the primary action and the `⋯`; an object with no action of its own got a full-width Edit and nothing else. A field's value is now edited by a tap on it, so on a phone: + +- The bottom bar draws the object's actions only: the primary and the next one (the default budget of 2 is unchanged), filling the row. The record's edit state keeps its Cancel and Save there. +- With no action to draw, no bottom bar is drawn and the page body runs to the foot of the screen. +- The `⋯` moves to the right end of the top bar. It holds Edit (on or off, with the reason when it is off), the actions that did not fit, Refresh, Share and Delete. (Favorites is not in it: the favorite star sits beside the record's name.) Edit there does what the bar's Edit did. +- A record pending the reader's approval is unchanged: the bar is the approval's decisions and its own `⋯`. +- The desktop header is unchanged. + +`page:header` `mobileMaxVisible` keeps its default of 2 in the phone bar, but Edit no longer takes one of those slots, so an unset budget now shows two of the page's actions where it showed one, and an authored value counts the page's actions alone. Host buttons still take bar slots ahead of the page's actions: the queue's Claim, and in the record's edit state its Cancel and Save. Its description in the spec, the designer and the docs says so. + +Migrating: an author who wants the earlier number of page actions in the phone bar lowers `mobileMaxVisible` by one. An authored `1` that meant "Edit only" now shows the primary action; to keep the bar free of inline actions, mark the page's actions `component: 'action:menu'` so they fold into the `⋯`. + +`@object-ui/components`: `PageHeaderPhoneFace` (the value of `PageHeaderPhoneContext`) gains an optional `more` slot. A host that hands it gets the `⋯` drawn there, and a bar with no button draws nothing; a host that does not keeps the `⋯` as the bar's last button, as before. diff --git a/content/docs/references/ui/component.mdx b/content/docs/references/ui/component.mdx index 3c9b07926cb..0b3c9f9b600 100644 --- a/content/docs/references/ui/component.mdx +++ b/content/docs/references/ui/component.mdx @@ -1580,7 +1580,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **showStar** | `never` | optional | [REMOVED] `page:header` property `showStar` was removed in @objectstack/spec 18 (ADR-0087 D2) — the console draws the record's star from the host's favorites toggle, never from metadata, so the key switched nothing. Delete the key, whether it was `true` or `false`; the page draws the same star without it. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **showCopyId** | `boolean` | optional (default: `true`) | Show the copy-record-id button beside the record title. Part of the record chrome — no effect when `recordChrome` is false. | | **maxVisible** | `integer` | optional | How many header actions render as inline buttons before the rest fold into the overflow menu. Renderer default when unset: 3 on every header. In a record page's header bar the number, authored or not, is an upper bound: actions that do not fit the bar's width fold as well, so a narrow drawer shows fewer. | -| **mobileMaxVisible** | `integer` | optional | The `maxVisible` budget on mobile viewports. Renderer default when unset: 2 in a record page's bottom action bar on a phone, where the host's Edit counts as one, 1 on any other header. | +| **mobileMaxVisible** | `integer` | optional | The `maxVisible` budget on mobile viewports. Renderer default when unset: 2 in a record page's bottom action bar on a phone, 1 on any other header. The phone bar holds the page's own actions: the record's Edit is not one of them, it is in the overflow menu at the top bar's right end. | | **aria** | `{ ariaLabel?: string \| Record; ariaDescribedBy?: string; role?: string }` | optional | ARIA accessibility attributes | ### Nested Shape: `PageHeaderProps.aria` diff --git a/content/docs/ui/components/page.mdx b/content/docs/ui/components/page.mdx index 8e0241a0e40..9402eeefbaf 100644 --- a/content/docs/ui/components/page.mdx +++ b/content/docs/ui/components/page.mdx @@ -56,7 +56,7 @@ Namespace `page`. | `recordChrome` | `boolean` | | Set false for the bare h1 header on non-record pages | | `showCopyId` | `boolean` | | — | | `maxVisible` | `number` | | How many header actions render as inline buttons on desktop before the rest fold into the overflow menu. A positive integer, defaulting to 3 — the contract rejects 0 and fractional values. In a record page's header bar, actions that do not fit its width fold too, so a narrow drawer shows fewer. Two kinds of action are routed to the overflow menu regardless of this budget and never occupy an inline slot: an action whose locations declare record_more without record_header, and any action with component action:menu. The host's own buttons (the record page's Edit) take no slot and never fold. The first inline action, or the one declaring variant primary, is the one filled primary button; the others are outline buttons. The host's Edit is always an outline button: on a record with no header action of its own the row has no filled button. An action declaring variant danger is never the primary: inline it is a destructive button, and in the overflow menu it is a red row below a separator. | -| `mobileMaxVisible` | `number` | | The same inline-button budget on mobile viewports, where horizontal room is scarce. A positive integer, defaulting to 1, or 2 in a record page's bottom action bar on a phone, where the host's Edit counts as one; the desktop half is Max Inline Actions, and the overflow routing rules stated there apply unchanged. | +| `mobileMaxVisible` | `number` | | The same inline-button budget on mobile viewports, where horizontal room is scarce. A positive integer, defaulting to 1, or 2 in a record page's bottom action bar on a phone, which holds the page's actions (the record's Edit is in the top bar's overflow menu there); the desktop half is Max Inline Actions, and the overflow routing rules stated there apply unchanged. | ## `page:section` [#page-section] diff --git a/content/docs/ui/pages.mdx b/content/docs/ui/pages.mdx index d074d725f38..3c42729c756 100644 --- a/content/docs/ui/pages.mdx +++ b/content/docs/ui/pages.mdx @@ -396,7 +396,7 @@ unknown or retired key (`description`, `icon`, `breadcrumb`, `showStar`) is refu | `placedActions` | — | `true` asks for every action of the object placed at `record_header` / `record_more`, read live, in place of an `actions` list, so an action another package adds is drawn without editing the page. Refused beside an authored `actions` list: keep one. The platform's user, organization and approval request pages set it | | `recordChrome` | `true` | Draw the title as the record chip (object label, copy-id button, the record's picture when the object names an `imageField`); `false` keeps a bare heading | | `showCopyId` | `true` | The copy-record-id button in the chip | -| `maxVisible` / `mobileMaxVisible` | 3 on every header (in a record page's header bar the number, authored or not, is an upper bound: actions that do not fit the bar's width fold as well) / 2 in a phone record page's bottom bar (the Edit button counts as one), 1 elsewhere | How many actions render inline before the rest fold into the `⋯` menu | +| `maxVisible` / `mobileMaxVisible` | 3 on every header (in a record page's header bar the number, authored or not, is an upper bound: actions that do not fit the bar's width fold as well) / 2 in a phone record page's bottom bar (the page's own actions; Edit is in the top bar's `⋯` there), 1 elsewhere | How many actions render inline before the rest fold into the `⋯` menu | | `aria` | — | ARIA attributes (`ariaLabel`, `ariaDescribedBy`, …) for the `
` element | A named action renders only if its `locations` include `record_header` (inline) or diff --git a/packages/spec/src/ui/component.zod.ts b/packages/spec/src/ui/component.zod.ts index fbe14df674c..5ce3d62ec48 100644 --- a/packages/spec/src/ui/component.zod.ts +++ b/packages/spec/src/ui/component.zod.ts @@ -856,7 +856,7 @@ export const PageHeaderProps = strictObject({ 'How many header actions render as inline buttons before the rest fold into the overflow menu. Renderer default when unset: 3 on every header. In a record page\'s header bar the number, authored or not, is an upper bound: actions that do not fit the bar\'s width fold as well, so a narrow drawer shows fewer.', ), mobileMaxVisible: z.number().int().positive().optional().describe( - 'The `maxVisible` budget on mobile viewports. Renderer default when unset: 2 in a record page\'s bottom action bar on a phone, where the host\'s Edit counts as one, 1 on any other header.', + 'The `maxVisible` budget on mobile viewports. Renderer default when unset: 2 in a record page\'s bottom action bar on a phone, 1 on any other header. The phone bar holds the page\'s own actions: the record\'s Edit is not one of them, it is in the overflow menu at the top bar\'s right end.', ), /** ARIA accessibility */ aria: AriaPropsSchema.optional().describe('ARIA accessibility attributes'), diff --git a/scripts/sdui-manifest.record.json b/scripts/sdui-manifest.record.json index 81ae70827fc..27d1cf562c2 100644 --- a/scripts/sdui-manifest.record.json +++ b/scripts/sdui-manifest.record.json @@ -13,8 +13,8 @@ ], "source": "built-tree", "generator": "scripts/gen-sdui-manifest-node.mjs", - "generatedAt": "2026-11-21", - "sha256": "16ff838b7448ca0e59019fe61016e0c4d3ab9654239fc4beded2238b801ee2cf", + "generatedAt": "2026-11-22", + "sha256": "f3dbc8227184b481722038c25df8027ec0b7546957cda33d6d718fe643ff3bf3", "components": 106, "inTree": { "modulesRoot": "ui/apps/console", diff --git a/sdui.manifest.json b/sdui.manifest.json index 1402ef27d30..e16a82c0592 100644 --- a/sdui.manifest.json +++ b/sdui.manifest.json @@ -3544,7 +3544,7 @@ { "name": "mobileMaxVisible", "type": "number", - "description": "The same inline-button budget on mobile viewports, where horizontal room is scarce. A positive integer, defaulting to 1, or 2 in a record page's bottom action bar on a phone, where the host's Edit counts as one; the desktop half is Max Inline Actions, and the overflow routing rules stated there apply unchanged." + "description": "The same inline-button budget on mobile viewports, where horizontal room is scarce. A positive integer, defaulting to 1, or 2 in a record page's bottom action bar on a phone, which holds the page's actions (the record's Edit is in the top bar's overflow menu there); the desktop half is Max Inline Actions, and the overflow routing rules stated there apply unchanged." } ] }, diff --git a/ui/e2e/record-flow-phone-targets.spec.ts b/ui/e2e/record-flow-phone-targets.spec.ts index 6199f9295c6..b5d80c8bfa2 100644 --- a/ui/e2e/record-flow-phone-targets.spec.ts +++ b/ui/e2e/record-flow-phone-targets.spec.ts @@ -102,7 +102,9 @@ const CLS = { composerRow: g('composer', /
{ const b = (cls: string, label: string, extra = '') => ``; @@ -133,6 +135,7 @@ const fixture = () => {
3 / 21 + ${b(CLS.topMore, 'TM')}
@@ -174,7 +177,7 @@ const fixture = () => {
- ${b(`gap-2 ${CLS.barButton}`, 'Edit')}${b(`gap-2 ${CLS.barButton}`, 'Convert Lead')}${b(CLS.barMore, 'MA')} + ${b(`gap-2 ${CLS.barButton}`, 'Convert Lead')}${b(`gap-2 ${CLS.barButton}`, 'Assign')}
`; }; diff --git a/ui/packages/app-shell/src/views/RecordDetailView.favoritesEntry-12427.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.favoritesEntry-12427.test.tsx index bd24859d86e..42e56943baa 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.favoritesEntry-12427.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.favoritesEntry-12427.test.tsx @@ -101,7 +101,7 @@ const METADATA = { const STORE_KEY = 'objectui-favorites'; const stored = (): FavoriteItem[] => JSON.parse(localStorage.getItem(STORE_KEY) ?? '[]'); -async function mountRecordPage(opts: { embedded?: boolean } = {}) { +async function mountRecordPage(opts: { embedded?: boolean; ready?: string } = {}) { const dataSource = { find: vi.fn(async () => ({ data: [] })), findOne: vi.fn(async () => ({ id: RECORD_ID, name: 'Intro call' })), @@ -139,7 +139,9 @@ async function mountRecordPage(opts: { embedded?: boolean } = {}) { , ); await waitFor(() => expect(dataSource.findOne).toHaveBeenCalled()); - await waitFor(() => expect(document.querySelector('[role="toolbar"]')).toBeTruthy()); + // The header's actions are drawn: its toolbar, or on a phone whose object + // declares no action of its own, the top bar's ⋯ (objectstack#36151). + await waitFor(() => expect(document.querySelector(opts.ready ?? '[role="toolbar"]')).toBeTruthy()); } /** The record header's favorite star, by either of its two names. */ @@ -156,8 +158,7 @@ function isFilled(star: HTMLElement): boolean { } /** Opens the header's overflow and returns its entries' text. */ -async function openOverflow(): Promise { - const [trigger] = screen.getAllByRole('button', { name: 'More actions' }); +async function openOverflow(trigger: HTMLElement = screen.getAllByRole('button', { name: 'More actions' })[0]): Promise { fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false, pointerType: 'mouse' }); await waitFor(() => expect(screen.getByRole('menu')).toBeInTheDocument()); return screen.getAllByRole('menuitem').map((el) => (el.textContent ?? '').trim()); @@ -277,7 +278,7 @@ describe('record page: the favorite star beside the record name, none in the ⋯ expect(items.filter((text) => /favorites$/.test(text))).toEqual([]); }); - it('a phone draws the star beside the name, and its bottom bar\'s ⋯ holds no favorites entry', async () => { + it('a phone draws the star beside the name, and the top bar\'s ⋯ holds no favorites entry', async () => { Object.defineProperty(window, 'innerWidth', { value: 390, configurable: true, writable: true }); const measure = HTMLElement.prototype.getBoundingClientRect; vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) { @@ -285,9 +286,17 @@ describe('record page: the favorite star beside the record name, none in the ⋯ return { x: 0, y: 0, top: 0, left: 0, right: 390, bottom: 800, width: 390, height: 800, toJSON: () => ({}) } as DOMRect; }); try { - await mountRecordPage(); - // CONTROL: the phone face is drawn — its bottom bar holds the actions. - await waitFor(() => expect(document.querySelector('[data-record-action-bar] [role="toolbar"]')).toBeTruthy()); + await mountRecordPage({ ready: '[data-record-phone-more] button[aria-label="More actions"]' }); + // CONTROL: the phone face is drawn. This object declares no action of + // its own, so its bottom bar is drawn empty (and hidden), and the + // record's ⋯ is the one at the top bar's right end (objectstack#36151). + const topMore = await waitFor(() => { + const trigger = document.querySelector('[data-record-phone-more] button[aria-label="More actions"]'); + expect(trigger).toBeTruthy(); + return trigger!; + }); + expect(document.querySelector('[data-record-action-bar]')!.childElementCount).toBe(0); + expect(screen.getAllByRole('button', { name: 'More actions' })).toEqual([topMore]); const star = await waitFor(() => { const [only, ...rest] = headerStars(); expect(rest).toHaveLength(0); @@ -299,8 +308,9 @@ describe('record page: the favorite star beside the record name, none in the ⋯ fireEvent.click(star); await waitFor(() => expect(stored()).toHaveLength(1)); - const items = await openOverflow(); - expect(items).toContain('Share'); + const items = await openOverflow(topMore); + // CONTROL: the top ⋯ is open and holds the record's Edit and Share. + expect(items).toEqual(expect.arrayContaining(['Edit', 'Share'])); expect(items.filter((text) => /favorites$/.test(text))).toEqual([]); } finally { vi.restoreAllMocks(); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.phoneFace-27058.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.phoneFace-27058.test.tsx index eba92544c6a..8ca7af68a7e 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.phoneFace-27058.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.phoneFace-27058.test.tsx @@ -18,10 +18,11 @@ * highlights (the strip of four that followed is gone since * objectstack#35891); * - Target 7, the bottom bar: the header's actions drawn below the body, in - * their bar face — the host's Edit, the primary and the `⋯`, however many - * actions the page declares (objectstack#34595; this file pinned Edit - * after the declared actions before); the header draws no action row of - * its own; + * their bar face — the primary and the next declared action, however many + * the page declares; the `⋯` at the top bar's right end holds the rest and + * Edit (objectstack#36151; before, the bar was [Edit][primary][⋯], + * objectstack#34595); with no declared action no bar is drawn; the header + * draws no action row of its own; * - Target 8, a page pushed from its parent's related row: its 「‹」 names * where it returns, the parent record (「‹ Mira Costa」), and it and the * path row's parent go back in the history, to the parent, whose own 「‹」 @@ -218,8 +219,22 @@ async function barDrawn(): Promise { ); } +/** The record's `⋯` at the top bar's right end (objectstack#36151). */ +const topMore = () => pageBar()!.querySelector('[data-record-phone-more] button[aria-label="More actions"]') as HTMLButtonElement | null; + +async function topMoreDrawn(): Promise { + return waitFor( + () => { + const more = topMore(); + expect(more).toBeTruthy(); + return more as HTMLButtonElement; + }, + { timeout: 5000 }, + ); +} + async function moreItems(): Promise { - fireEvent.pointerDown(within(actionBar()!).getByRole('button', { name: 'More actions' }), { + fireEvent.pointerDown(await topMoreDrawn(), { button: 0, ctrlKey: false, pointerType: 'mouse', @@ -321,11 +336,11 @@ describe('the record page on a phone (objectstack#27058)', () => { expect(document.body.textContent).toContain('Austin'); }); - it('the bottom bar: [Edit][Convert Lead][⋯] with the declared second action in the ⋯; the header draws no action row (objectstack#34595)', async () => { + it('the bottom bar: [Convert Lead][Assign], the page\'s actions only; the header draws no action row (objectstack#36151)', async () => { mountPage([`/apps/${APP}/${LEAD}/record/r-1`]); const toolbar = await barDrawn(); expect(toolbar.getAttribute('data-page-header-actions-face')).toBe('bar'); - expect(barButtons()).toEqual(['Edit', 'Convert Lead', 'More actions']); + expect(barButtons()).toEqual(['Convert Lead', 'Assign']); // The header above the body has no toolbar of its own, and the bar is // below the body, not in it. const header = document.querySelector('[data-record-page-root] header') as HTMLElement; @@ -333,17 +348,63 @@ describe('the record page on a phone (objectstack#27058)', () => { expect(within(header).queryByRole('toolbar')).toBeNull(); expect(header.contains(actionBar())).toBe(false); expect(actionBar()!.contains(header)).toBe(false); + // The `⋯` is the top bar's last control, not the bottom bar's, and it + // holds Edit with the host's chrome. + expect(actionBar()!.querySelector('button[aria-label="More actions"]')).toBeNull(); + const more = await topMoreDrawn(); + expect(pageBar()!.querySelector('[data-record-top-bar-controls]')!.lastElementChild!.contains(more)).toBe(true); const items = await moreItems(); - expect(items).toContain('Assign'); - expect(items).not.toContain('Edit'); + expect(items).toEqual(expect.arrayContaining(['Edit', 'Share'])); + expect(items).not.toContain('Convert Lead'); + expect(items).not.toContain('Assign'); }); - it('the bottom bar with one declared action: [Edit][Convert Lead][⋯] (objectstack#34595)', async () => { + it('a third declared action folds into the top bar\'s ⋯, after Refresh and before Edit (objectstack#36151)', async () => { + mountPage([`/apps/${APP}/${LEAD}/record/r-1`], objectsWith([action('convert', 'Convert Lead'), action('assign', 'Assign'), action('call', 'Log Call')])); + await barDrawn(); + expect(barButtons()).toEqual(['Convert Lead', 'Assign']); + const items = await moreItems(); + expect(items.indexOf('Log Call')).toBeGreaterThanOrEqual(0); + expect(items.indexOf('Log Call')).toBeLessThan(items.indexOf('Edit')); + }); + + it('the bottom bar with one declared action: [Convert Lead] alone, the whole row (objectstack#36151)', async () => { mountPage([`/apps/${APP}/${LEAD}/record/r-1`], objectsWith([action('convert', 'Convert Lead')])); await barDrawn(); - const buttons = barButtons(); - expect(buttons.slice(0, 2)).toEqual(['Edit', 'Convert Lead']); - expect(buttons.length).toBeLessThanOrEqual(3); + expect(barButtons()).toEqual(['Convert Lead']); + const only = actionBar()!.querySelector('[role="toolbar"] > button') as HTMLButtonElement; + expect(only.className.split(/\s+/)).toContain('flex-1'); + }); + + it('no declared action: no bottom bar is drawn, and Edit is in the top bar\'s ⋯ (objectstack#36151)', async () => { + const onEdit = vi.fn(); + const objects = objectsWith([]); + render( + + + + } + /> + + + , + ); + await topMoreDrawn(); + await waitFor(() => expect(document.body.textContent).toContain('mira@atlas.test')); + // The host's bar element is there, and empty: `empty:hidden` leaves it out. + expect(actionBar()).toBeTruthy(); + expect(actionBar()!.childElementCount).toBe(0); + expect(actionBar()!.className.split(/\s+/)).toContain('empty:hidden'); + // 「更多」→「编辑」 is the Edit the bar's first button was: it opens the + // record's edit, as before. + fireEvent.pointerDown(topMore()!, { button: 0, ctrlKey: false, pointerType: 'mouse' }); + const menu = await screen.findByRole('menu'); + const edit = within(menu).getByRole('menuitem', { name: 'Edit' }); + expect(edit.getAttribute('aria-disabled')).not.toBe('true'); + fireEvent.click(edit); + await waitFor(() => expect(onEdit).toHaveBeenCalledWith({ id: 'r-1' }, LEAD)); }); it('a page pushed from its parent\'s related row: 「‹ Mira Costa」 goes back to the parent, whose 「‹」 reads 「Leads」', async () => { @@ -436,7 +497,8 @@ describe('the record page on a phone (objectstack#27058)', () => { * - phone, approval-locked: the bar is the same group, Approve the only * filled button and pressable; an approval lock draws no Edit * (objectstack#35593, #35419); - * - control: the same page with no request keeps [Edit][Convert Lead][⋯]. + * - control: the same page with no request draws [Convert Lead][Assign], + * Edit pressable in the top bar's `⋯` (objectstack#36151). */ const APPROVAL_OBJECT = 'sys_approval_request'; const REQUEST_ID = 'req-35016'; @@ -551,30 +613,33 @@ describe('one ⋯ per screen on a record pending approval (objectstack#35016)', expect(items).not.toContain('Edit'); }); - it('control: no request, the bar keeps [Edit][Convert Lead][⋯] with Edit pressable', async () => { + it('control: no request, the bar is [Convert Lead][Assign] and Edit is pressable in the top bar\'s ⋯', async () => { stubApprovals(null); mountApprovalPage(); await barDrawn(); - expect(barButtons()).toEqual(['Edit', 'Convert Lead', 'More actions']); - const first = actionBar()!.querySelector('[role="toolbar"] button') as HTMLButtonElement; - expect(first.disabled).toBe(false); + expect(barButtons()).toEqual(['Convert Lead', 'Assign']); expect(screen.queryByTestId('declared-actions-decision-menu')).toBeNull(); + fireEvent.pointerDown(await topMoreDrawn(), { button: 0, ctrlKey: false, pointerType: 'mouse' }); + const menu = await screen.findByRole('menu'); + expect(within(menu).getByRole('menuitem', { name: 'Edit' }).getAttribute('aria-disabled')).not.toBe('true'); }); }); /** * objectstack#35099 — the phone bar's first slot goes to a pressable action * whatever turns Edit off, not only the approval lock (objectstack#35016, - * pinned above): + * pinned above). Since objectstack#36151 Edit is in the top bar's `⋯` on a + * phone whether it is on or off; these pin that an Edit that is off is still + * drawn there, off: * * - `userActions.edit.disabledWhen` holding on the record; * - `editLockedByState` — every field the edit form shows read-only by its * `readonlyWhen` — with its badge still drawn as the reason; * - * each time Edit sits in the bar's `⋯`, still drawn and still off, and the - * first declared action leads the bar. Controls: the desktop row keeps Edit - * greyed in place for all three reasons, and a `disabledWhen` that does not - * hold leaves Edit leading the bar, pressable. + * each time Edit sits in the top bar's `⋯`, still drawn and still off, and + * the first declared action leads the bar. Controls: the desktop row keeps + * Edit greyed in place for all three reasons, and a `disabledWhen` that does + * not hold leaves Edit in the `⋯`, pressable. */ const LOCKS_NEW = "record.status == 'new'"; @@ -612,10 +677,10 @@ async function desktopRowEdit(): Promise { async function expectEditInBarOverflowOff() { await barDrawn(); - await waitFor(() => expect(barButtons()).toEqual(['Convert Lead', 'Assign', 'More actions'])); + await waitFor(() => expect(barButtons()).toEqual(['Convert Lead', 'Assign'])); const first = actionBar()!.querySelector('[role="toolbar"] button') as HTMLButtonElement; expect(first.disabled).toBe(false); - fireEvent.pointerDown(within(actionBar()!).getByRole('button', { name: 'More actions' }), { button: 0, ctrlKey: false, pointerType: 'mouse' }); + fireEvent.pointerDown(await topMoreDrawn(), { button: 0, ctrlKey: false, pointerType: 'mouse' }); const menu = await screen.findByRole('menu'); // By accessible name: an entry that says why it is off carries the reason // as a second line, and its name stays the label (objectstack#35135). @@ -628,23 +693,24 @@ describe('a phone bar never leads with an Edit that is off, for any reason (obje __resetRecordApprovalsStore(); }); - it('phone, edit.disabledWhen holds: Edit is in the bar\'s ⋯, off, and Convert Lead leads', async () => { + it('phone, edit.disabledWhen holds: Edit is in the top bar\'s ⋯, off, and Convert Lead leads', async () => { mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadWithDisabledEdit(LOCKS_NEW)); await expectEditInBarOverflowOff(); }); - it('phone, editLockedByState: Edit is in the bar\'s ⋯, off, Convert Lead leads, and the badge states why', async () => { + it('phone, editLockedByState: Edit is in the top bar\'s ⋯, off, Convert Lead leads, and the badge states why', async () => { mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadLockedByState()); await waitFor(() => expect(screen.getByTestId('record-state-lock').textContent).toBe('Not editable in its current state'), { timeout: 5000 }); await expectEditInBarOverflowOff(); }); - it('control, phone: a disabledWhen that does not hold keeps [Edit][Convert Lead][⋯] with Edit pressable', async () => { + it('control, phone: a disabledWhen that does not hold leaves Edit pressable in the top bar\'s ⋯', async () => { mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadWithDisabledEdit("record.status == 'closed'")); await barDrawn(); - await waitFor(() => expect(barButtons()).toEqual(['Edit', 'Convert Lead', 'More actions'])); - const first = actionBar()!.querySelector('[role="toolbar"] button') as HTMLButtonElement; - expect(first.disabled).toBe(false); + await waitFor(() => expect(barButtons()).toEqual(['Convert Lead', 'Assign'])); + fireEvent.pointerDown(await topMoreDrawn(), { button: 0, ctrlKey: false, pointerType: 'mouse' }); + const menu = await screen.findByRole('menu'); + expect(within(menu).getByRole('menuitem', { name: 'Edit' }).getAttribute('aria-disabled')).not.toBe('true'); }); it('control, desktop: edit.disabledWhen keeps Edit greyed in place in the header row', async () => { @@ -682,7 +748,7 @@ describe('a phone bar never leads with an Edit that is off, for any reason (obje * - desktop: the header row's Edit is described by the reason, and its * wrapper opens it as a tooltip; the `⋯`'s Delete shows it as its second * line; - * - phone: the bar's `⋯` entry for Edit shows it as its second line. + * - phone: the top bar's `⋯` entry for Edit shows it as its second line. * * Controls: the approval band and the state-lock badge explain their own * locks, so an Edit they turn off gives no second, generic reason; a @@ -714,7 +780,7 @@ describe('a disabledWhen-greyed Edit or Delete says why (objectstack#35135)', () expect(edit.parentElement!.hasAttribute('data-disabled-reason')).toBe(true); }); - it('phone, edit.disabledWhen holds: the bar\'s ⋯ entry for Edit shows the reason', async () => { + it('phone, edit.disabledWhen holds: the top bar\'s ⋯ entry for Edit shows the reason', async () => { mountPage([`/apps/${APP}/${LEAD}/record/r-1`], leadWithDisabledEdit(LOCKS_NEW)); await expectEditInBarOverflowOff(); const menu = screen.getByRole('menu'); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.recordPageTiers-26678.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.recordPageTiers-26678.test.tsx index bc32e7603d5..c839499cb96 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.recordPageTiers-26678.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.recordPageTiers-26678.test.tsx @@ -24,7 +24,8 @@ * - Narrower (the split pane at 720, a phone at 390): ONE column, the * details as the first tab, 「详情」, of the record's tab row (Target 8). * On a phone (objectstack#27058: a 390 px window, not only a 390 px root) - * the header's actions sit in the bottom bar after it. + * the header's actions sit in the bottom bar after it, and its `⋯` at the + * top bar's right end (objectstack#36151). * - The embedded record (drawer / split pane) never pins. * - History is read at open in every tier. `?tab=` addresses no strip; * `?related=timeline` is the 动态 tab, the full stream. @@ -350,14 +351,17 @@ describe('RecordDetailView — one record page, laid out by its width (objectsta await waitFor(() => expect(auditReads()).toBeGreaterThan(0)); // objectstack#27058 — on a phone the stack ends where the bottom action // bar starts: the header's actions are drawn there, after the body, and - // the header draws no action row. The split pane keeps the header's + // the header draws no action row. This object declares no action, so the + // bar is left empty (not drawn) and the header's `⋯` is at the top bar's + // right end (objectstack#36151). The split pane keeps the header's // group, in the page's one top row (objectstack#35593). const bar = container.querySelector('[data-record-action-bar]'); const header = container.querySelector('[data-record-page-root] header') as HTMLElement; if (name === 'a phone') { - await waitFor(() => expect(bar?.querySelector('[role="toolbar"]')).toBeTruthy()); + await waitFor(() => expect(container.querySelector('[data-record-phone-more] button[aria-label="More actions"]')).toBeTruthy()); const details = column(container, 'details')!; expect(details.compareDocumentPosition(bar!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + expect(bar!.childElementCount).toBe(0); expect(header.querySelector('[role="toolbar"]')).toBeNull(); } else { expect(bar).toBeNull(); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.tsx b/ui/packages/app-shell/src/views/RecordDetailView.tsx index 809b659044f..6bdeefe761d 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.tsx @@ -4831,6 +4831,9 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri // read where the page is assigned, above.) const phonePage = phone && !embedded; const [phoneActionBarEl, setPhoneActionBarEl] = useState(null); + // objectstack#36151 — the top bar's right end, where the record's `⋯` is + // drawn on a phone (Edit among its entries). + const [phoneMoreEl, setPhoneMoreEl] = useState(null); const [pageScrollerEl, setPageScrollerEl] = useState(null); useRecordPageScrollMemory(phonePage ? pageScrollerEl : null, pageRecordStatus === 'loaded'); @@ -5252,7 +5255,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri // in the header row whether or not the record has app actions // (objectstack#36049; before, it drew filled when it had none); // `page:header` decides that — no `variant` is declared here for it - // to read. The phone's bottom bar still draws it filled. + // to read. icon: 'pencil', type: 'script', locations: ['record_header'], @@ -5294,15 +5297,13 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri // button's tooltip and accessible description, and as the second // line of its `⋯` entry (the phone bar's, where an off Edit goes). ...(editReason ? { disabledReason: editReason } : null), - // objectstack#35016, objectstack#35099 — on a phone the bottom bar's - // first slot is its primary place, and an action that cannot be - // pressed never holds it: whichever of the three reasons above turns - // this Edit off, it moves into the bar's `⋯` (still drawn, still - // off), and the first usable action takes the slot. The approval band - // states the lock, and the `editLockedByState` badge the state lock. - // The desktop row keeps it greyed in place for every reason, and an - // Edit that is on is untouched. - ...(phonePage && editOff ? { component: 'action:menu' } : {}), + // objectstack#36151 — on a phone Edit is an entry of the `⋯` at the + // top bar's right end, on or off: a field's value is edited by a tap + // on it, and the bottom bar holds the object's own actions, or is not + // drawn when it has none. An Edit that is off is still drawn there, + // off, with its reason (objectstack#35099, objectstack#35135). The + // desktop row keeps it a button, greyed in place when it is off. + ...(phonePage ? { component: 'action:menu' } : {}), // objectstack#35599 — a page drawing body tables enters its edit state; // every other page opens the record form, as before. onClick: () => (recordEditEligible @@ -5806,6 +5807,8 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri stepper={pageStepper} toggles={approvalQueueSwitch ?? undefined} comments={phoneCommentsButton} + // objectstack#36151 — the record's `⋯`, at the bar's right end. + frame={} /> {phonePathRow} @@ -6258,7 +6261,7 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri into the bottom bar below, and the default page's header takes its subtitle from the declared text highlights. */} {/* objectstack#27058, Target 7 — the phone's bottom action bar: the - header's action row in its bar face (the primary action, one more - and the `⋯`), at the foot of the page above the safe area, so - the body ends where the bar starts. Empty, it is not drawn. */} + header's action row in its bar face (the primary action and one + more; the `⋯` is in the top bar, objectstack#36151), at the foot + of the page above the safe area, so the body ends where the bar + starts. Empty, it is not drawn, and the body runs to the foot. */} {phonePage && (
)} diff --git a/ui/packages/components/src/__tests__/page-header-phone-bar-27058.test.tsx b/ui/packages/components/src/__tests__/page-header-phone-bar-27058.test.tsx index 7b9469e8c5d..932336a1a72 100644 --- a/ui/packages/components/src/__tests__/page-header-phone-bar-27058.test.tsx +++ b/ui/packages/components/src/__tests__/page-header-phone-bar-27058.test.tsx @@ -248,3 +248,68 @@ describe('the phone bar keeps Edit visible on an editable record (objectstack#34 expect(labels).toEqual(['Generate Quote', 'Clone Opportunity', 'Print', 'Edit', 'More actions']); }); }); + +/** + * objectstack#36151 — a phone host that hands a top-bar slot for the `⋯` + * (`PageHeaderPhoneContext.more`): the bottom bar holds the action buttons + * alone, filling the row, and the `⋯` is drawn in the slot; with no button to + * draw the bar is left empty. The console's record page hands its Edit as a + * menu entry there (`component: 'action:menu'`), so it is one of the `⋯`'s + * entries. Control: without the slot (every test above) the `⋯` stays the + * bar's last button. + */ +describe('the phone bar with the host\'s top-bar ⋯ slot (objectstack#36151)', () => { + const MENU_EDIT = [ + { name: 'sys_edit', label: 'Edit', component: 'action:menu' }, + { name: 'sys_delete', label: 'Delete' }, + ]; + + function TopBarHost({ schema, mountMore = true }: { schema: unknown; mountMore?: boolean }) { + const [barEl, setBarEl] = React.useState(null); + const [moreEl, setMoreEl] = React.useState(null); + const face = React.useMemo(() => ({ actionBar: barEl, more: moreEl }), [barEl, moreEl]); + return ( + + {mountMore && } + + + + + +
+ + ); + } + + const topMore = () => screen.getByTestId('top-more'); + + it('the bar is the page\'s two actions, filling the row; the ⋯ is in the slot and holds the rest and Edit', async () => { + render(); + await waitFor(() => expect(bar().querySelector('[role="toolbar"]')).not.toBeNull()); + expect(barButtons()).toEqual(['Convert Lead', 'Assign']); + for (const b of within(bar()).getAllByRole('button')) expect(b.className.split(/\s+/)).toContain('flex-1'); + expect(within(bar()).queryByRole('button', { name: 'More actions' })).toBeNull(); + await waitFor(() => expect(within(topMore()).getByRole('button', { name: 'More actions' })).toBeTruthy()); + expect(await openMore(topMore())).toEqual(['Return', 'Edit', 'Delete']); + }); + + it('with no page action the bar draws nothing, and the ⋯ in the slot holds Edit', async () => { + render(); + await waitFor(() => expect(within(topMore()).getByRole('button', { name: 'More actions' })).toBeTruthy()); + expect(bar().childElementCount).toBe(0); + expect(await openMore(topMore())).toEqual(['Edit', 'Delete']); + }); + + it('nothing is drawn for the ⋯ until the slot exists; the bar\'s buttons still are', async () => { + render(); + await waitFor(() => expect(bar().querySelector('[role="toolbar"]')).not.toBeNull()); + expect(barButtons()).toEqual(['Convert Lead']); + expect(screen.queryByRole('button', { name: 'More actions' })).toBeNull(); + }); +}); diff --git a/ui/packages/components/src/renderers/layout/containers.tsx b/ui/packages/components/src/renderers/layout/containers.tsx index 3e6e8640456..39a0019b4e2 100644 --- a/ui/packages/components/src/renderers/layout/containers.tsx +++ b/ui/packages/components/src/renderers/layout/containers.tsx @@ -1921,11 +1921,11 @@ function recordPictureUrl(value: unknown): string | undefined { } /** - * The buttons a phone's bottom action bar holds before its `⋯` - * (objectstack#27058): on an editable record, Edit and the primary action - * (objectstack#34595); else the primary action and one more. The record page v4 - * header row's cap is the primary, two more and the `⋯`; at 390 px the second - * of those folds into the `⋯`. + * The buttons a phone's bottom action bar holds (objectstack#27058): the + * primary action and one more. A host button the record page puts in the bar + * (the edit state's Cancel and Save, a queue's Claim) takes a slot like any + * other; the record page's Edit is not one of them on a phone, it sits in the + * `⋯` (objectstack#36151; before, it took the first slot, objectstack#34595). */ const PHONE_ACTION_BAR_BUTTONS = 2; @@ -1947,7 +1947,7 @@ export interface PageHeaderActionsProps { placedActions?: unknown; /** The inline-button budget on desktop, as `page:header`'s `maxVisible`; an out-of-contract value falls back to the unset default, 3 on every header. In a record page's header bar (`fitWidth`) the number is an upper bound: what does not fit the bar's width folds as well. */ maxVisible?: unknown; - /** The inline-button budget on mobile, as `page:header`'s `mobileMaxVisible`; an out-of-contract value falls back to the unset default: 2 in a record page's phone bottom bar (`face: 'bar'`, the host's Edit included), 1 on any other header. */ + /** The inline-button budget on mobile, as `page:header`'s `mobileMaxVisible`; an out-of-contract value falls back to the unset default: 2 in a record page's phone bottom bar (`face: 'bar'`), 1 on any other header. */ mobileMaxVisible?: unknown; /** Drawn in place of the action row when no action survives the gates. */ emptySlot?: React.ReactNode; @@ -1968,10 +1968,11 @@ export interface PageHeaderActionsProps { * Where the row is drawn (objectstack#27058). `row` (the default) is the * header's own action row. `bar` is a phone's bottom action bar: the primary * action, one more and the `⋯`, each button sharing the bar's width. In the - * bar the host's Edit takes a slot like any other button, but the first - * one (objectstack#34595): on an editable record the bar is Edit, the - * primary action, then the `⋯` holding the rest. The page's - * `mobileMaxVisible` still sets the budget when it declares one. + * bar a host button (the edit state's Cancel and Save) takes a slot like any + * other, ahead of the page's actions. The page's `mobileMaxVisible` still + * sets the budget when it declares one. When the phone host hands a top-bar + * slot (`PageHeaderPhoneContext.more`, objectstack#36151) the `⋯` is drawn + * there and the bar holds the buttons alone, nothing when there are none. */ face?: 'row' | 'bar'; /** @@ -2060,6 +2061,9 @@ export const PageHeaderActions: React.FC = ({ // the row is what that group draws — the record's row unchanged, or the // state's own levers with the record's actions in their `⋯`. const stateGroup = React.useContext(RecordHeaderStateContext)?.group; + // objectstack#36151 — the phone host's top-bar slot for the `⋯`: handed, the + // bottom bar keeps the action buttons alone. `undefined` = no such slot. + const phoneMoreSlot = React.useContext(PageHeaderPhoneContext)?.more; // Record-level inline-edit session (objectui#2572 item 4): while a shared // inline draft is active, header actions flagged `disableDuringInlineEdit` // (the host's Edit CTA) grey out so the classic form-edit surface can't be @@ -2713,10 +2717,10 @@ export const PageHeaderActions: React.FC = ({ // The phone's bottom bar (objectstack#27058) has room for its budget and // no more, so there every button queues for the same slots and what does // not fit folds into the `⋯`. The queue is the bar's order - // (objectstack#34595): the host's buttons first — on an editable record - // that is its Edit, the record's base action, which the row never folds - // either — then the primary, then the page's other actions. So the - // default budget of two draws [Edit][primary][⋯] however many actions + // (objectstack#34595): the host's buttons first — the edit state's Cancel + // and Save — then the primary, then the page's other actions. The record + // page hands its Edit to the `⋯` on a phone (objectstack#36151), so the + // default budget of two draws [primary][next action] however many actions // the page declares. A destructive host action is not a host button (see // `isHostButton`): it still always folds. const authoredButtons = ranked.filter((a) => !isHostAction(a)); @@ -2856,9 +2860,8 @@ export const PageHeaderActions: React.FC = ({ // record's name, though the record's fields edit in place. It now // draws outline there too; the page's own actions keep their pick and // their faces, and a host button DECLARING `variant: 'primary'` (the - // edit state's Save, objectstack#35816) stays filled. The phone's - // bottom bar keeps its filled Edit: there it is the bar's one big - // target. + // edit state's Save, objectstack#35816) stays filled. In the phone's + // bottom bar a host button that is the pick keeps the filled face. const hostEditPick = action === primaryAction && !barFace && isHostAction(action) && action?.variant !== 'primary'; const variant = @@ -2997,17 +3000,21 @@ export const PageHeaderActions: React.FC = ({ {refresh.label} ) : null; - const recordRowItems = ( - <> - {inlineActions.map(renderButton)} - {useOverflow && ( + // objectstack#36151 — with the host's top-bar slot the bar's `⋯` is drawn + // there, a ghost icon like the top bar's other controls, at touch size; + // the bar holds the buttons alone. + const moreInTopBar = barFace && phoneMoreSlot !== undefined; + const overflowMenu = useOverflow ? ( @@ -3022,7 +3029,13 @@ export const PageHeaderActions: React.FC = ({ {overflowActions.map((action, idx) => renderMenuItem(action, idx, 'more', firstDestructiveIdx))} - )} + ) : null; + const recordRowItems = ( + <> + {inlineActions.map(renderButton)} + {moreInTopBar + ? overflowMenu && phoneMoreSlot ? createPortal(overflowMenu, phoneMoreSlot) : null + : overflowMenu} ); // A state group (objectstack#35593) takes the record's actions as `⋯` @@ -3075,6 +3088,12 @@ export const PageHeaderActions: React.FC = ({
); } + // objectstack#36151 — a bar whose `⋯` is in the top bar and that has no + // button to draw draws nothing, so the host's bar stays empty (and the + // host leaves it out); the `⋯` is still drawn in its slot. + if (moreInTopBar && !stateGroup && inlineActions.length === 0 && !hasTrailing) { + return recordRowItems; + } return (