diff --git a/.changeset/35853-record-header-two-rows.md b/.changeset/35853-record-header-two-rows.md new file mode 100644 index 00000000000..b6fef1276f2 --- /dev/null +++ b/.changeset/35853-record-header-two-rows.md @@ -0,0 +1,19 @@ +--- +'@objectstack/spec': patch +'@object-ui/components': patch +'@object-ui/app-shell': patch +--- + +feat(record-page): the record's header is two rows — navigation over the record — and shows up to three actions again + +Clause-②: yes (widening) — `@object-ui/components` takes four optional members: `RecordTopBarProps.record`, `RecordTopBarStepper.onScope`, `NavigationOverlayProps.recordRow` and `PageHeaderActionsProps.fitWidth`; nothing removed or renamed +Metadata-protocol: none + +The record's top bar, on the full page and in the drawer alike, is now two rows: + +- The navigation row (40 px). From a list: ↑ ↓ and 「第 N 条,共 M 条 · 视图名」 ("N of M · view"), M being the records the list matched; the view's name returns to the list. From no list (a link, a notification, a search): the object's name and no ↑ ↓; on the page the name links to the object's list, and in the drawer it is shown without a link. ✕ sits at the far right in every case: on the page it returns to the list the page came from as it was left, else the object's default list; in the drawer it closes, with ⤢ (open the full page) before it. +- The record row (48 px): the record's icon, its name one size larger, its stage and approval tags, then who else is on the record and the managing package's badge (on the page they no longer float over the corner above the tabs), and at the right the record's buttons and ⊟. + +The drawer shows ↑ ↓ and the count again (the drawer hid them since #35593). A phone keeps its one-row bar. + +The header bar's default inline budget is 3 again (#35593 had set it to 1): what does not fit the bar's width folds into 「更多」 one action at a time, down to the primary, so a narrow drawer shows fewer. An authored `maxVisible` still wins, a phone still shows one primary action (its bottom bar holds the host's Edit and one more), and there is still one primary-coloured button at a time. The `page:header` `maxVisible` / `mobileMaxVisible` describe, the `pages.mdx` Default cell and the Studio designer descriptions say so. diff --git a/content/docs/references/ui/component.mdx b/content/docs/references/ui/component.mdx index f247467ddaf..22cc601e118 100644 --- a/content/docs/references/ui/component.mdx +++ b/content/docs/references/ui/component.mdx @@ -1579,8 +1579,8 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **recordChrome** | `boolean` | optional (default: `true`) | Render the record chrome — the title as a record chip with its copy-id button. Set false on a non-record page (dashboard, landing) to fall back to the bare heading layout. | | **showStar** | `never` | optional | [REMOVED] `page:header` property `showStar` was removed in @objectstack/spec 18 (ADR-0087 D2) — the reference console draws no star beside the record title, so the key switched nothing: the record's favorites entry is the header's ⋯ menu, and metadata does not control it. Delete the key, whether it was `true` or `false`; the ⋯ menu's favorites entry is unchanged. 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: 1 in a record page's one-row header bar, 3 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. | +| **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. | | **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 c08eeb8c346..5b2c2bf2385 100644 --- a/content/docs/ui/components/page.mdx +++ b/content/docs/ui/components/page.mdx @@ -55,8 +55,8 @@ Namespace `page`. | `placedActions` | `boolean` | | Set true to draw every action of the object placed at record_header or record_more, read live from the object's metadata, in place of an Actions list: an action another package adds to the object is drawn without editing the page. Refused beside an authored Actions list: keep one. | | `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 — the contract rejects 0 and fractional values. 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. 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; when unset it is 2 in a record page's bottom action bar on a phone (counting the host's Edit) and 1 on any other header. The desktop half is Max Inline Actions, and the overflow routing rules stated there apply unchanged. | +| `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. 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. | ## `page:section` [#page-section] diff --git a/content/docs/ui/pages.mdx b/content/docs/ui/pages.mdx index 0851ac0d29b..6036db13b74 100644 --- a/content/docs/ui/pages.mdx +++ b/content/docs/ui/pages.mdx @@ -300,7 +300,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` | 1 in a record page's one-row header bar, 3 elsewhere / 2 in a phone record page's bottom bar, 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 Edit button counts as one), 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/docs/qa/platform-checklist/areas/records-forms.json b/docs/qa/platform-checklist/areas/records-forms.json index 6fd674d1d47..cbd4c2e175d 100644 --- a/docs/qa/platform-checklist/areas/records-forms.json +++ b/docs/qa/platform-checklist/areas/records-forms.json @@ -7411,6 +7411,116 @@ "ref": "#35783" } ] + }, + { + "id": "records-forms.record-open-path-and-header", + "title": "An object's list opens a record one way — the name opens the full page, the hover icon beside it the side drawer — and the record's header is two rows: the way through the list (↑ ↓, 「第 N 条,共 M 条 · 视图名」, ✕) over the record (its name, chips and up to three actions), with the tabs right under it", + "since": "v18.7", + "status": "active", + "revision": 1, + "priority": "P1", + "surface": "browser", + "personas": [ + "seeded admin (admin@objectos.ai / admin123)" + ], + "fixtures": { + "app": "showcase", + "requires": [ + "a fresh boot of the showcase (the live lane's `ui/e2e/live/ci/start-backend.sh`, or `pnpm dev -- --fresh --seed-admin`)", + "the showcase_account list (14 seeded accounts, a synthesized record page with a tab row) and the showcase_task list (its showcase_task_detail page authors three record_header actions: Mark Done, Log Time, Archive)" + ] + }, + "steps": [ + "at 1280×900 open the showcase_account list and click the second account's name; read the URL and the header's two rows", + "reload the page; read the navigation row again; press ↓; then click the view's name (「All Records」) in the navigation row", + "on the list, hover the second row and click the 「在侧边打开」 icon beside the name; read the URL, the drawer's edges and its header; press ↓ in the drawer, then its 「整页打开」", + "paste the address of an account record into a fresh tab (no list behind it); read the navigation row; click ✕", + "open a backlog task from the showcase_task list and read the record row's buttons; open a task in the drawer at 820 px wide and read them again", + "at 390×844 with touch, open the account list and tap a record" + ], + "acceptance": [ + { + "clause": "the record's name opens the full page and nothing else does: no reader setting and no `navigation.mode` picks the drawer instead", + "oracle": "dom", + "verify": "after steps[0] the URL is …/showcase_account/record/ with no ?recordId=, and no drawer card ([data-record-drawer-card]) is drawn", + "evidence": "the URL and a screenshot" + }, + { + "clause": "the page remembers the list it came from, across a reload: ↑ ↓ walk the list's rows in its order, the navigation row reads 「2 of 14 · All Records」, and the view's name goes back to the list", + "oracle": "dom", + "verify": "[data-record-top-bar-position] reads '2 of 14' and [data-record-top-bar-scope] 'All Records' before and after the reload; after ↓ the position reads '3 of 14'; the scope click lands on the list", + "evidence": "the navigation row before and after the reload" + }, + { + "clause": "the icon beside the name, shown while the row is hovered, opens the record in a side drawer over the list, a floating card 8 px off the window's top, right and bottom edges, with 「整页打开」 and ✕ and no full-width state", + "oracle": "dom", + "verify": "the icon's opacity is 0 at rest and 1 on hover; after the click the URL carries ?recordId=, the list is still drawn, the card's box is 8 px from three edges with a rounded corner, and its frame holds exactly two buttons", + "evidence": "the drawer screenshot" + }, + { + "clause": "the header is two rows on the page and in the drawer: a 40 px navigation row (the stepper and position, or the object when no list is behind it; ✕ at its far right) over a 48 px record row (icon, the name at 16 px, chips, actions)", + "oracle": "dom", + "verify": "[data-record-top-bar-rows='2'] holds [data-record-top-bar-nav] (40 px) above [data-record-top-bar-record] (48 px); the close button ends within 12 px of the row's right edge; with no list behind it there is no [data-record-top-bar-stepper] and the object crumb shows, and ✕ goes to the object's list", + "evidence": "the three figure-40 screenshots" + }, + { + "clause": "the record row shows three authored actions by default, and folds those that do not fit its width into ⋯ rather than wrapping", + "oracle": "dom", + "verify": "on a backlog task Mark Done, Log Time and Archive stand inline beside Edit and ⋯; in the 820 px drawer every visible button of [data-record-top-bar-actions] shares one top", + "evidence": "both screenshots" + }, + { + "clause": "the page's first row (its tab row, or a stage bar) starts right under the header, with no blank band", + "oracle": "dom", + "verify": "the tab row's top minus the header's bottom is at most 12 px, on the page and in the drawer", + "evidence": "the measured gap" + }, + { + "clause": "on a phone there is no side-drawer icon; a tap opens the page, whose one-row bar still knows the list", + "oracle": "dom", + "verify": "no [data-testid='record-open-in-panel'] is drawn; after the tap the URL is the record's page and the bar reads '2 / 14', also after a reload", + "evidence": "the phone screenshot" + }, + { + "clause": "the pins pass at the run subject sha", + "oracle": "test", + "verify": "run ui/e2e/live/record-open-path-35854.spec.ts and ui/e2e/live/record-topbar-35853.spec.ts with the live config (playwright.live.config.ts), and ui/packages/app-shell/src/views/ObjectView.recordOpenPath-35854.test.tsx and ui/packages/components/src/__tests__/record-top-bar-two-rows-35853.test.tsx from ui/ with vitest; each reports ≥1 test and 0 failed", + "evidence": "the Playwright and vitest summary lines, with the subject sha" + } + ], + "negative": [ + "a name click that opens the drawer, or a 「打开记录:抽屉 / 整页」 setting anywhere in the list's view settings, is a FAIL", + "a page opened from a list that loses its position or view name on a reload is a FAIL", + "a list view declaring navigation.mode 'none' (or preventNavigation) whose rows open a record is a FAIL: 'none' still means rows open nothing", + "a blank band of more than 12 px between the header and the tab row is a FAIL" + ], + "traps": [ + "hydration-race", + "shared-browser-tab" + ], + "automated": { + "kind": "e2e", + "ref": "ui/e2e/live/record-open-path-35854.spec.ts (name → page, hover icon → drawer, provenance across a reload, phone), ui/e2e/live/record-topbar-35853.spec.ts (the two rows on the page and in the drawer, three actions, the width fold, the gap above the tabs, the phone bar); both in the live lane, not in the required `:ci` allowlist" + }, + "source": [ + "ui/packages/app-shell/src/views/objectViewRecordNavigation.ts", + "ui/packages/app-shell/src/views/objectViewOpenAsPage.tsx#OpenInSidePanelButton", + "ui/packages/app-shell/src/views/recordDrawerStack.tsx#useRecordPageReturn", + "ui/packages/components/src/custom/record-top-bar.tsx#RecordTopBar", + "ui/packages/components/src/custom/navigation-overlay.tsx", + "ui/packages/components/src/renderers/layout/containers.tsx#PageHeaderActions", + "ui/packages/app-shell/src/views/RecordDetailView.tsx", + "#35854", + "#35853" + ], + "history": [ + { + "revision": 1, + "date": "2026-11-20", + "change": "initial — the one open path (#35854, maintainer ruling 「废弃」 on the open preference and navigation.mode) and the two-row record header (#35853, with the gap above the tabs of #35745), read from the PR branch and driven live against the showcase", + "ref": "#35854" + } + ] } ] } diff --git a/packages/spec/src/ui/component.zod.ts b/packages/spec/src/ui/component.zod.ts index 1978360506c..be958fa3c15 100644 --- a/packages/spec/src/ui/component.zod.ts +++ b/packages/spec/src/ui/component.zod.ts @@ -839,8 +839,9 @@ export const PageHeaderProps = strictObject({ * evidence: the renderer has always read them and the schema had not caught * up. The header renderer (read points recorded in `liveness/page.json`, row `regions`) resolves * `schema?.maxVisible ?? schema?.properties?.maxVisible` (and the `mobile*` - * twin), the fallbacks for an unset key are its own (they differ by host, as - * the two `.describe()` strings below state), and its comment says out loud + * twin), the fallbacks for an unset key are its own (3 on desktop, folded + * by width in a record page's header bar since #35853; the mobile one + * differs by host — as the two `.describe()` strings below state), and its comment says out loud * that both are "overridable on the page:header". Closing this shape * without declaring them would turn an invited affordance into a hard * rejection — the lesson of commit 78f0be872, which is to enumerate by the RENDERER'S read @@ -852,10 +853,10 @@ export const PageHeaderProps = strictObject({ * as the record picker's `limit` docblock records for its own 50. */ maxVisible: z.number().int().positive().optional().describe( - 'How many header actions render as inline buttons before the rest fold into the overflow menu. Renderer default when unset: 1 in a record page\'s one-row header bar, 3 on any other header.', + '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, 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, where the host\'s Edit counts as one, 1 on any other header.', ), /** ARIA accessibility */ aria: AriaPropsSchema.optional().describe('ARIA accessibility attributes'), diff --git a/scripts/sdui-manifest.record.json b/scripts/sdui-manifest.record.json index 23723388330..31605bd4997 100644 --- a/scripts/sdui-manifest.record.json +++ b/scripts/sdui-manifest.record.json @@ -14,7 +14,7 @@ "source": "built-tree", "generator": "scripts/gen-sdui-manifest-node.mjs", "generatedAt": "2026-11-21", - "sha256": "3711e7efc78c869ee5c1d8e1b16c8cf718ac87a7c9db3bdb602483684e6065f9", + "sha256": "6d9807f35ed3bc4d4dc727fe6fe9ad76c8667cc5666daef03336b5df28bcda69", "components": 106, "inTree": { "modulesRoot": "ui/apps/console", diff --git a/sdui.manifest.json b/sdui.manifest.json index 1a7ff3fa7fd..2ca21407a4a 100644 --- a/sdui.manifest.json +++ b/sdui.manifest.json @@ -3539,12 +3539,12 @@ { "name": "maxVisible", "type": "number", - "description": "How many header actions render as inline buttons on desktop before the rest fold into the overflow menu. A positive integer — the contract rejects 0 and fractional values. 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. 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." + "description": "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. 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." }, { "name": "mobileMaxVisible", "type": "number", - "description": "The same inline-button budget on mobile viewports, where horizontal room is scarce. A positive integer; when unset it is 2 in a record page's bottom action bar on a phone (counting the host's Edit) and 1 on any other header. 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, where the host's Edit counts as one; the desktop half is Max Inline Actions, and the overflow routing rules stated there apply unchanged." } ] }, diff --git a/ui/apps/console/src/pages/system/ApprovalsInboxPage.queueStepper-34586.test.tsx b/ui/apps/console/src/pages/system/ApprovalsInboxPage.queueStepper-34586.test.tsx index 622b417051d..7dd60baf296 100644 --- a/ui/apps/console/src/pages/system/ApprovalsInboxPage.queueStepper-34586.test.tsx +++ b/ui/apps/console/src/pages/system/ApprovalsInboxPage.queueStepper-34586.test.tsx @@ -241,8 +241,8 @@ describe('the approvals queue steps from request to request (objectstack#34586)' await waitFor(() => expect(counter()).not.toBeNull()); expect(counter()).toHaveAttribute('aria-label', '1 of 3 in Approvals Inbox'); expect(screen.getByTestId('approval-queue-open-next')).toBeInTheDocument(); - // The crumb leads back to the inbox, by its name. - expect(document.querySelector('[data-record-crumb-object]')).toHaveTextContent('Approvals Inbox'); + // The navigation row leads back to the inbox, by its name (objectstack#35853). + expect(document.querySelector('[data-record-top-bar-scope]')).toHaveTextContent('Approvals Inbox'); fireEvent.click(document.querySelector('[data-record-top-bar-step="next"]') as HTMLElement); await waitFor(() => expect(where()).toBe(pageOf('req_b'))); diff --git a/ui/e2e/live/record-open-path-35854.spec.ts b/ui/e2e/live/record-open-path-35854.spec.ts index 9ef990c0f2f..23e11a8f52d 100644 --- a/ui/e2e/live/record-open-path-35854.spec.ts +++ b/ui/e2e/live/record-open-path-35854.spec.ts @@ -7,9 +7,9 @@ import { test, expect, type Page } from '@playwright/test'; * The record's name opens the full page; the icon shown beside the name while * the row is hovered (「在侧边打开」) opens the side drawer over the list, which * stays. The page remembers the list it came from (its view, its order, the - * loaded window) in the history entry, so ↑ / ↓ walk that list, the counter - * names the view, and a reload keeps all of it. On a phone (a coarse pointer, - * no hover) there is no icon: the name opens the page. + * loaded window) in the history entry, so ↑ / ↓ walk that list, 「第 N 条,共 M + * 条 · 视图名」 names it, and a reload keeps all of it. On a phone (a coarse + * pointer, no hover) there is no icon: the name opens the page. * * The unit pins of each path are beside the code * (`ObjectView.recordOpenPath-35854.test.tsx`, `recordDrawerStack-26679`); this @@ -24,7 +24,7 @@ const NAME = '[data-testid="primary-field-link"]'; const ICON = '[data-testid="record-open-in-panel"]'; const CARD = '[data-record-drawer-card]'; const POSITION = '[data-record-top-bar-position]'; -const TITLE = '[data-record-top-bar] h1'; +const SCOPE = '[data-record-top-bar-scope]'; async function openList(page: Page) { await page.goto(LIST); @@ -45,23 +45,24 @@ test.describe('record open path at 1280 px', () => { await expect(page).toHaveURL(recordPath); await expect(page.locator(CARD)).toHaveCount(0); - await expect(page.locator(TITLE)).toContainText(name); - await expect(page.locator(POSITION)).toHaveText(`2 / ${total}`); - await expect(page.locator(POSITION)).toHaveAttribute('aria-label', `2 of ${total} in All Records`); + await expect(page.locator('[data-record-top-bar-title]')).toContainText(name); + await expect(page.locator(POSITION)).toHaveText(`2 of ${total}`); + await expect(page.locator(SCOPE)).toHaveText('All Records'); // The provenance lives in the history entry: a reload keeps it. await page.reload(); - await expect(page.locator(TITLE)).toContainText(name); - await expect(page.locator(POSITION)).toHaveText(`2 / ${total}`); - await expect(page.locator(POSITION)).toHaveAttribute('aria-label', `2 of ${total} in All Records`); + await expect(page.locator('[data-record-top-bar-title]')).toContainText(name); + await expect(page.locator(POSITION)).toHaveText(`2 of ${total}`); + await expect(page.locator(SCOPE)).toHaveText('All Records'); - // ↓ walks the list in its order. + // ↓ walks the list in its order, still named. + const third = (await page.evaluate(() => (history.state?.usr?.from?.siblings ?? [])[2]?.label ?? null)) as string | null; await page.locator('[data-record-top-bar-step="next"]').click(); - await expect(page.locator(POSITION)).toHaveText(`3 / ${total}`); - await expect(page.locator(TITLE)).not.toContainText(name); + await expect(page.locator(POSITION)).toHaveText(`3 of ${total}`); + if (third) await expect(page.locator('[data-record-top-bar-title]')).toContainText(third); - // The object crumb goes back to the list. - await page.getByTestId('record-page-crumb').click(); + // The view's name goes back to the list, as it was left. + await page.locator(SCOPE).click(); await expect(page).toHaveURL(new RegExp(`${LIST.replace(/\./g, '\\.')}(/view/[^/?#]+)?([?#].*)?$`)); await expect(page.locator(NAME).nth(2)).toBeVisible(); }); @@ -83,7 +84,7 @@ test.describe('record open path at 1280 px', () => { await expect(page).toHaveURL(/[?&]recordId=/); const card = page.locator(CARD); await expect(card).toBeVisible(); - await expect(card.locator(TITLE)).toContainText(name); + await expect(card.locator('[data-record-top-bar-title]')).toContainText(name); // The list stays under it. await expect(page.locator(NAME).first()).toBeVisible(); @@ -95,17 +96,18 @@ test.describe('record open path at 1280 px', () => { expect(Math.round(vp.height - (box.y + box.height))).toBe(8); expect(parseFloat(await card.evaluate((e) => getComputedStyle(e).borderTopLeftRadius))).toBeGreaterThanOrEqual(8); - // No full-width state: 「整页打开」 and close, no maximize toggle. + // No full-width state: the frame holds 「整页打开」 and close, nothing else. + const frame = card.locator('[data-record-top-bar-frame] button'); + await expect(frame).toHaveCount(2); await expect(card.getByTestId('record-pane-open-page')).toBeVisible(); - await expect(card.getByRole('button', { name: /full width|maximi[sz]e|restore/i })).toHaveCount(0); // 「整页打开」 leaves for the page, which still knows its list. await card.getByTestId('record-pane-open-page').click(); await expect(page).toHaveURL(recordPath); - await expect(page.locator(POSITION)).toHaveAttribute('aria-label', /in All Records$/); + await expect(page.locator(SCOPE)).toHaveText('All Records'); }); - test('a page opened with no list behind it has no stepper; its object crumb goes to the object list', async ({ page }) => { + test('a page opened with no list behind it has no stepper; its close goes to the object list', async ({ page }) => { await openList(page); const href = await page.locator(NAME).nth(1).getAttribute('href'); expect(href).toBeTruthy(); @@ -113,12 +115,12 @@ test.describe('record open path at 1280 px', () => { // A direct visit: a pasted link, a notification, a search hit. await page.goto(href!); - await expect(page.locator(TITLE)).toBeVisible(); - await expect(page.locator('[data-record-top-bar-step]')).toHaveCount(0); + await expect(page.locator('[data-record-top-bar-rows="2"]')).toBeVisible(); + await expect(page.locator('[data-record-top-bar-stepper]')).toHaveCount(0); await expect(page.locator(POSITION)).toHaveCount(0); await expect(page.getByTestId('record-page-crumb')).toBeVisible(); - await page.getByTestId('record-page-crumb').click(); + await page.getByTestId('record-page-close').click(); await expect(page.locator(NAME).nth(2)).toBeVisible(); }); }); diff --git a/ui/e2e/live/record-topbar-35853.spec.ts b/ui/e2e/live/record-topbar-35853.spec.ts new file mode 100644 index 00000000000..1352790bac1 --- /dev/null +++ b/ui/e2e/live/record-topbar-35853.spec.ts @@ -0,0 +1,189 @@ +import { test, expect, type Locator, type Page } from '@playwright/test'; + +/** + * Live e2e: the record header in two rows (objectstack-ai/objectstack#35853). + * + * Row 1, the navigation row (40 px): ↑ / ↓ and 「第 N 条,共 M 条 · 视图名」 when + * the record was opened from a list, the object when it was not, and ✕ at the + * far right on every face (with 「整页打开」 before it in the drawer). Row 2, the + * record row (48 px): the icon, the record's name one size larger, its chips, + * and its actions — three authored buttons by default, folding into ⋯ when the + * row is too narrow for them. The page's first row of content (its tab row) + * starts right under the header, with no blank band (objectstack#35745: at most + * 12 px). On a phone the bar is the one-row phone bar. + * + * Drives the real Console against the real showcase backend. The task record + * page (`showcase_task_detail`) authors three `record_header` actions; the + * account page is synthesized, with a tab row. + */ + +const APP = 'com.example.showcase'; +const NAME = '[data-testid="primary-field-link"]'; +const BAR = '[data-record-top-bar-rows="2"]'; +const NAV = '[data-record-top-bar-nav]'; +const RECORD = '[data-record-top-bar-record]'; + +async function openFromList(page: Page, object: string, index = 1) { + await page.goto(`/apps/${APP}/${object}`); + await expect(page.locator(NAME).nth(index + 1)).toBeVisible(); + const name = (await page.locator(NAME).nth(index).textContent())!.trim(); + await page.locator(NAME).nth(index).click(); + await expect(page.locator(BAR)).toBeVisible(); + return name; +} + +async function box(l: Locator) { + const b = await l.boundingBox(); + expect(b, 'element has a box').toBeTruthy(); + return b!; +} + +/** Every visible authored button sits on one line: the toolbar does not wrap. */ +async function actionsOnOneLine(scope: Locator) { + return scope.locator('[data-record-top-bar-actions]').evaluate((el) => { + const tops = [...el.querySelectorAll('button')] + .filter((b) => b.getClientRects().length > 0) + .map((b) => Math.round(b.getBoundingClientRect().top)); + return tops.length > 0 && tops.every((t) => t === tops[0]); + }); +} + +test.describe('record header at 1280 px', () => { + test.use({ viewport: { width: 1280, height: 900 } }); + + test('a page opened from a list: navigation row over record row, ✕ at the far right', async ({ page }) => { + const name = await openFromList(page, 'showcase_account'); + const bar = page.locator(BAR); + const nav = bar.locator(NAV); + const record = bar.locator(RECORD); + + // Two rows, 40 then 48, the navigation row on top. + const navBox = await box(nav); + const recordBox = await box(record); + expect(Math.round(navBox.height)).toBe(40); + expect(Math.round(recordBox.height)).toBe(48); + expect(recordBox.y).toBeGreaterThanOrEqual(navBox.y + navBox.height - 1); + + // Row 1 holds the way through the list, not the record. + await expect(nav.locator('[data-record-top-bar-step="previous"]')).toBeVisible(); + await expect(nav.locator('[data-record-top-bar-step="next"]')).toBeVisible(); + await expect(nav.locator('[data-record-top-bar-position]')).toHaveText(/^2 of \d+$/); + await expect(nav.locator('[data-record-top-bar-scope]')).toHaveText('All Records'); + await expect(nav).not.toContainText(name); + + // ✕ is the last thing on row 1, at its right edge. + const close = nav.getByTestId('record-page-close'); + await expect(close).toBeVisible(); + const closeBox = await box(close); + expect(navBox.x + navBox.width - (closeBox.x + closeBox.width)).toBeLessThanOrEqual(12); + + // Row 2 holds the record: its name, one size larger (16 px), and its actions. + const title = record.locator('[data-record-top-bar-title]'); + await expect(title).toContainText(name); + const fontSize = await title.locator('h1, [data-record-page-title]').first().evaluate((e) => getComputedStyle(e).fontSize); + expect(fontSize).toBe('16px'); + await expect(record.getByRole('button', { name: 'Edit' })).toBeVisible(); + + // objectstack#35745 — no blank band between the header and the tab row. + const tabs = page.locator('[data-record-tab-row]').first(); + await expect(tabs).toBeVisible(); + const barBox = await box(bar); + const tabsBox = await box(tabs); + expect(tabsBox.y - (barBox.y + barBox.height)).toBeLessThanOrEqual(12); + }); + + test('a page opened with no list: the object on row 1, ✕ to its list, no stepper', async ({ page }) => { + await page.goto(`/apps/${APP}/showcase_account`); + const href = await page.locator(NAME).nth(1).getAttribute('href'); + await page.goto(href!); + const nav = page.locator(BAR).locator(NAV); + + await expect(nav.getByTestId('record-page-crumb')).toBeVisible(); + await expect(nav.locator('[data-record-top-bar-stepper]')).toHaveCount(0); + await expect(nav.getByTestId('record-page-close')).toBeVisible(); + + await nav.getByTestId('record-page-close').click(); + await expect(page).toHaveURL(new RegExp(`/apps/${APP.replace(/\./g, '\\.')}/showcase_account(/view/[^/?#]+)?([?#].*)?$`)); + }); + + test('the header shows three authored actions by default, on one line', async ({ page }) => { + // The task page authors Mark Done, Log Time and Archive as record_header + // actions (Mark Done hides on a finished task), plus the host's Edit. + await openFromList(page, 'showcase_task', 2); + const record = page.locator(BAR).locator(RECORD); + const actions = record.locator('[data-record-top-bar-actions]'); + + await expect(actions.getByRole('button', { name: 'Log Time' })).toBeVisible(); + await expect(actions.getByRole('button', { name: 'Archive' })).toBeVisible(); + await expect(actions.getByRole('button', { name: 'Edit' })).toBeVisible(); + // The authored actions beyond three, and record_more, are under ⋯. + await expect(actions.getByRole('button', { name: /more/i })).toBeVisible(); + expect(await actionsOnOneLine(record)).toBe(true); + }); + + test('in the drawer: the same two rows, 「整页打开」 and ✕ at the far right, the tabs right under', async ({ page }) => { + await page.goto(`/apps/${APP}/showcase_account`); + const row = page.locator(NAME).nth(1); + const name = (await row.textContent())!.trim(); + await row.hover(); + await page.locator('[data-testid="record-open-in-panel"]').nth(1).click(); + + const card = page.locator('[data-record-drawer-card]'); + const bar = card.locator(BAR); + await expect(bar).toBeVisible(); + const nav = bar.locator(NAV); + await expect(nav.locator('[data-record-top-bar-position]')).toHaveText(/^2 of \d+$/); + await expect(nav.locator('[data-record-top-bar-scope]')).toHaveText('All Records'); + await expect(bar.locator(RECORD).locator('[data-record-top-bar-title]')).toContainText(name); + + const frame = nav.locator('[data-record-top-bar-frame] button'); + await expect(frame).toHaveCount(2); + await expect(frame.nth(0)).toHaveAttribute('data-testid', 'record-pane-open-page'); + const navBox = await box(nav); + const closeBox = await box(frame.nth(1)); + expect(navBox.x + navBox.width - (closeBox.x + closeBox.width)).toBeLessThanOrEqual(12); + + const tabs = card.locator('[data-record-tab-row]').first(); + await expect(tabs).toBeVisible(); + const barBox = await box(bar); + expect((await box(tabs)).y - (barBox.y + barBox.height)).toBeLessThanOrEqual(12); + expect(await actionsOnOneLine(bar.locator(RECORD))).toBe(true); + + // ↓ steps to the next record of the list inside the drawer. + await nav.locator('[data-record-top-bar-step="next"]').click(); + await expect(nav.locator('[data-record-top-bar-position]')).toHaveText(/^3 of \d+$/); + }); + + test('a narrow drawer folds actions that do not fit into ⋯ instead of wrapping', async ({ page }) => { + await page.setViewportSize({ width: 820, height: 900 }); + await page.goto(`/apps/${APP}/showcase_task`); + const row = page.locator(NAME).nth(2); + await row.hover(); + await page.locator('[data-testid="record-open-in-panel"]').nth(2).click(); + const record = page.locator('[data-record-drawer-card]').locator(BAR).locator(RECORD); + await expect(record.locator('[data-record-top-bar-actions]')).toBeVisible(); + await expect.poll(() => actionsOnOneLine(record)).toBe(true); + // The title keeps its room: it is not squeezed off the row. + expect((await box(record.locator('[data-record-top-bar-title]'))).width).toBeGreaterThanOrEqual(120); + }); +}); + +test.describe('record header at 390 px (touch)', () => { + test.use({ viewport: { width: 390, height: 844 }, isMobile: true, hasTouch: true }); + + test('the phone bar is one row and does not overflow the screen', async ({ page }) => { + await page.goto(`/apps/${APP}/showcase_account`); + const card = page.getByTestId('grid-mobile-card').nth(1); + await expect(card).toBeVisible(); + await card.getByTestId('grid-card-title').tap(); + + const bar = page.locator('[data-record-top-bar]').first(); + await expect(bar).toBeVisible(); + await expect(page.locator(BAR)).toHaveCount(0); + await expect(bar.locator('[data-record-top-bar-position]')).toHaveText(/^2 \/ \d+$/); + const b = await box(bar); + expect(b.x).toBeGreaterThanOrEqual(0); + expect(b.x + b.width).toBeLessThanOrEqual(390); + expect(await page.evaluate(() => document.documentElement.scrollWidth)).toBeLessThanOrEqual(390); + }); +}); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.accessibleNames-12625.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.accessibleNames-12625.test.tsx index e9e69570681..5d9d1c430e7 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.accessibleNames-12625.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.accessibleNames-12625.test.tsx @@ -186,12 +186,13 @@ describe('objectui#12625 — the record page names its regions, header actions a it('the header actions are named by their labels', async () => { const user = userEvent.setup(); await mountLeadPage(); - // objectstack#35593 — the one-row header draws ONE inline action; the - // rest are the ⋯'s items, each named by its label. + // objectstack#35853 — the header bar draws up to three inline actions, + // each a button named by its label; the ⋯ holds the system entries. expect(screen.getByRole('button', { name: 'Log a Call' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Log a Meeting' })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Schedule a Meeting' })).toBeInTheDocument(); await user.click(screen.getByRole('button', { name: 'More actions' })); - expect(await screen.findByRole('menuitem', { name: 'Log a Meeting' })).toBeInTheDocument(); - expect(screen.getByRole('menuitem', { name: 'Schedule a Meeting' })).toBeInTheDocument(); + expect((await screen.findAllByRole('menuitem')).length).toBeGreaterThan(0); }); it('the collapsible field group header is a button named by its label that toggles', async () => { diff --git a/ui/packages/app-shell/src/views/RecordDetailView.headerMenuIcons-12529.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.headerMenuIcons-12529.test.tsx index 17b493b7456..7017d38c5f4 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.headerMenuIcons-12529.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.headerMenuIcons-12529.test.tsx @@ -203,9 +203,10 @@ describe('record header: iconed system entries, Delete set apart in the ⋯, Edi it('the ⋯ holds the system group with Delete last, after a separator; Edit is not in it', async () => { await mountRecordPage(FULL_ROW); const menu = await openOverflow(); - // The host's Refresh leads the ⋯, set apart (objectstack#27055); the app - // actions past the row's one inline slot (objectstack#35593) come next. - expect(menuRows(menu)).toEqual(['Refresh', '---', 'Schedule Follow-up', 'Log a Call', 'Add to favorites', 'Share', '---', 'Delete']); + // The host's Refresh leads the ⋯, set apart (objectstack#27055); the three + // app actions fit the bar's three inline slots (objectstack#35853), so the + // system group follows. + expect(menuRows(menu)).toEqual(['Refresh', '---', 'Add to favorites', 'Share', '---', 'Delete']); }); it('with three app actions in the header, the first leads, Edit stays a labelled button after it, opens the edit session, and nothing is icon-only', async () => { @@ -213,8 +214,9 @@ describe('record header: iconed system entries, Delete set apart in the ⋯, Edi const bar = toolbar(); const buttons = Array.from(bar.querySelectorAll(':scope > button, :scope > span > button')); const names = buttons.map((b) => b.getAttribute('aria-label') ?? text(b)); - // objectstack#35593 — the one-row header: Edit, ONE app action, the ⋯. - expect(names).toEqual(['Convert Lead', 'Edit', 'More actions']); + // objectstack#35853 — the header bar's budget is 3 again (objectstack#35593 + // had made it 1): the three app actions, Edit, the ⋯. + expect(names).toEqual(['Convert Lead', 'Schedule Follow-up', 'Log a Call', 'Edit', 'More actions']); const edit = screen.getByRole('button', { name: 'Edit' }); expect(text(edit)).toBe('Edit'); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.topBar-27524.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.topBar-27524.test.tsx index 8a374e4b08f..a7196de929e 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.topBar-27524.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.topBar-27524.test.tsx @@ -10,14 +10,16 @@ * objectstack#27524, Target 7 — the record's top bar on each face, from a real * `RecordDetailView` mount (the `panelToggles-27052` harness). * - * - the page opened directly: the breadcrumb 「对象 › 记录名」 (the object goes - * to the object's list), ⊟ where the tier has a right column, nothing else - * — no counter, no ↓ ↑, no ⤡; the crumb row is gone; - * - the page the list's record name opened (objectstack#35854): the counter - * over the list's matched total (its tooltip naming the list's view), ↓ ↑ - * and `j` / `k` over the list's rows — a step replaces the page with the - * sibling's — and the object crumb back to the list; no ⤡ (the - * 「Collapse to drawer」 hop retired); + * Two rows on a desktop since objectstack#35853 (figure 40): the navigation + * row over the record row. + * + * - the page opened directly: the navigation row names the object (a link to + * the object's list) and ends in ✕, which goes there too; no counter, no + * ↑ ↓; the record row holds the header's name and ⊟; + * - the page the list's record name opened (objectstack#35854): ↑ ↓ and + * 「N of M · view」 over the list's matched total — a step replaces the page + * with the sibling's, `j` / `k` step too — and ✕ or the view's name back to + * the list as it was left; no ⤡ (the 「Collapse to drawer」 hop retired); * - the page under a `?from=` trail: ← and the path, each ancestor a link; * - the record in a pane: the pane's bar names it at the root, and its ⊟ sits * in that bar, not in the header's action row. @@ -25,7 +27,7 @@ import * as React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import { render, screen, cleanup, fireEvent, waitFor } from '@testing-library/react'; +import { render, screen, cleanup, fireEvent, waitFor, within } from '@testing-library/react'; import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; import { MetadataCtx } from '@object-ui/react'; import { RelatedCountStore } from '@object-ui/components'; @@ -154,38 +156,51 @@ afterEach(() => { vi.restoreAllMocks(); }); -describe('the page\'s top bar (objectstack#27524, Target 7)', () => { - it('opened directly: 「对象 / 记录名」 and ⊟, nothing else; the crumb row is gone', async () => { +describe('the page\'s top bar (objectstack#27524, Target 7; two rows since objectstack#35853)', () => { + it('opened directly: the navigation row names the object, ✕ at its right; the record row holds the name and ⊟', async () => { mountPage(`/apps/${APP}/${LEAD}/record/r-1`); await screen.findByRole('group', { name: 'Panels' }, { timeout: 5000 }); const bar = pageBar()!; expect(bar).not.toBeNull(); - // objectstack#35593 — the record's header holds the bar: the crumb names - // the object, then 「/」 and the header's own H1. - await waitFor(() => expect(bar.querySelector('[data-record-bar-title] h1')?.textContent).toBe('Record r-1')); - expect(screen.getByTestId('record-page-crumb').textContent).toBe('Leads'); - expect(bar.querySelector('[data-record-bar-separator]')?.textContent).toBe('/'); - const object = bar.querySelector('[data-record-crumb-object]') as HTMLAnchorElement; + // objectstack#35853 — two rows: navigation over the record. + const nav = bar.querySelector('[data-record-top-bar-nav]') as HTMLElement; + const record = bar.querySelector('[data-record-top-bar-record]') as HTMLElement; + await waitFor(() => expect(record.querySelector('[data-record-bar-title] h1')?.textContent).toBe('Record r-1')); + expect(nav.querySelector('[data-record-bar-title]')).toBeNull(); + // No list: the object's name, a link to the object's list, and no ↑ ↓. + expect(within(nav).getByTestId('record-page-crumb').textContent).toBe('Leads'); + const object = nav.querySelector('[data-record-crumb-object]') as HTMLAnchorElement; expect(object.getAttribute('href')).toBe(`/apps/${APP}/${LEAD}`); expect(bar.querySelector('[data-record-top-bar-step]')).toBeNull(); expect(bar.querySelector('[data-record-top-bar-position]')).toBeNull(); - expect(screen.queryByTestId('record-drawer-return')).toBeNull(); - expect(bar.querySelector('[role="group"][aria-label="Panels"]')).not.toBeNull(); + expect(bar.querySelector('[data-record-bar-separator]')).toBeNull(); + // ✕ is the navigation row's last control, and goes to the object's list. + const frame = nav.querySelector('[data-record-top-bar-frame]') as HTMLElement; + expect(frame.lastElementChild?.getAttribute('data-testid')).toBe('record-page-close'); + expect(record.querySelector('[role="group"][aria-label="Panels"]')).not.toBeNull(); expect(document.querySelector('[data-record-crumb-row]')).toBeNull(); + fireEvent.click(screen.getByTestId('record-page-close')); + await waitFor(() => expect(where()).toBe(`/apps/${APP}/${LEAD}`)); }); - it('opened by the list\'s record name: the counter over the list\'s matched total, ↓ ↑ and j / k over its rows', async () => { + it('opened by the list\'s record name: 「N of M · view」 over the list\'s matched total, ↑ ↓ and j / k over its rows', async () => { const from = { pathname: `/apps/${APP}/${LEAD}`, label: 'All leads', siblings: ROWS, total: 40 }; mountPage({ pathname: `/apps/${APP}/${LEAD}/record/r-2`, state: { from } }); await screen.findByRole('group', { name: 'Panels' }, { timeout: 5000 }); - const position = () => pageBar()!.querySelector('[data-record-top-bar-position]'); - expect(position()?.textContent).toBe('2 / 40'); + const nav = () => pageBar()!.querySelector('[data-record-top-bar-nav]') as HTMLElement; + const position = () => nav().querySelector('[data-record-top-bar-position]'); + expect(position()?.textContent).toBe('2 of 40'); expect(position()?.getAttribute('title')).toBe('2 of 40 in All leads'); + expect(nav().querySelector('[data-record-top-bar-scope]')?.textContent).toBe('All leads'); + // The figure's order: ↑ then ↓, then the count; no object crumb beside them. + const steps = Array.from(nav().querySelectorAll('[data-record-top-bar-step]')).map((el) => el.getAttribute('data-record-top-bar-step')); + expect(steps).toEqual(['previous', 'next']); + expect(nav().querySelector('[data-record-crumb-object]')).toBeNull(); expect(screen.queryByTestId('record-drawer-return')).toBeNull(); fireEvent.click(screen.getByRole('button', { name: 'Next record' })); await waitFor(() => expect(where()).toBe(`/apps/${APP}/${LEAD}/record/r-3`)); - await waitFor(() => expect(position()?.textContent).toBe('3 / 40')); + await waitFor(() => expect(position()?.textContent).toBe('3 of 40')); // The end of the rows the list loaded: ↓ stops there, even short of the total. expect((screen.getByRole('button', { name: 'Next record' }) as HTMLButtonElement).disabled).toBe(true); // `k` steps back; the arrow keys are the page's scroll, not the bar's. @@ -195,19 +210,18 @@ describe('the page\'s top bar (objectstack#27524, Target 7)', () => { await waitFor(() => expect(where()).toBe(`/apps/${APP}/${LEAD}/record/r-2`)); }); - it('control: with no total reported the counter counts the rows handed along', async () => { + it('control: with no total reported the counter counts the rows handed along; the first has no ↑', async () => { const from = { pathname: `/apps/${APP}/${LEAD}`, label: 'All leads', siblings: ROWS }; mountPage({ pathname: `/apps/${APP}/${LEAD}/record/r-1`, state: { from } }); await screen.findByRole('group', { name: 'Panels' }, { timeout: 5000 }); const position = () => pageBar()!.querySelector('[data-record-top-bar-position]'); - expect(position()?.textContent).toBe('1 / 3'); + expect(position()?.textContent).toBe('1 of 3'); expect(position()?.getAttribute('title')).toBe('1 of 3 in All leads'); - // The object crumb is the list it came from. - expect(pageBar()!.querySelector('[data-record-crumb-object]')?.getAttribute('href')).toBe(`/apps/${APP}/${LEAD}`); + expect((screen.getByRole('button', { name: 'Previous record' }) as HTMLButtonElement).disabled).toBe(true); fireEvent.keyDown(document.body, { key: 'j' }); await waitFor(() => expect(where()).toBe(`/apps/${APP}/${LEAD}/record/r-2`)); - await waitFor(() => expect(position()?.textContent).toBe('2 / 3')); + await waitFor(() => expect(position()?.textContent).toBe('2 of 3')); // The next page keeps the same list. expect(JSON.parse(screen.getByTestId('where-state').textContent!)).toEqual({ from }); fireEvent.click(screen.getByRole('button', { name: 'Previous record' })); @@ -221,17 +235,18 @@ describe('the page\'s top bar (objectstack#27524, Target 7)', () => { expect(pageBar()!.querySelector('[data-record-top-bar-step]')).toBeNull(); }); - it('the object crumb returns to the list the page came from, as it was left, with no record open', async () => { - mountPage({ pathname: `/apps/${APP}/${LEAD}/record/r-1`, state: { from: { pathname: `/apps/${APP}/${LEAD}?view=all`, label: 'All leads', siblings: ROWS } } }); - const object = await waitFor(() => { - const el = pageBar()?.querySelector('[data-record-crumb-object]'); - expect(el).toBeTruthy(); - return el as HTMLElement; - }); - expect(object.textContent).toBe('Leads'); - fireEvent.click(object); - await waitFor(() => expect(where()).toBe(`/apps/${APP}/${LEAD}?view=all`)); - }); + it.each([['✕', 'record-page-close'], ['the view\'s name', 'scope']])( + '%s returns to the list the page came from, as it was left, with no record open', + async (_name, control) => { + mountPage({ pathname: `/apps/${APP}/${LEAD}/record/r-1`, state: { from: { pathname: `/apps/${APP}/${LEAD}?view=all`, label: 'All leads', siblings: ROWS } } }); + await screen.findByRole('group', { name: 'Panels' }, { timeout: 5000 }); + const target = control === 'scope' + ? pageBar()!.querySelector('[data-record-top-bar-scope]') as HTMLElement + : screen.getByTestId('record-page-close'); + fireEvent.click(target); + await waitFor(() => expect(where()).toBe(`/apps/${APP}/${LEAD}?view=all`)); + }, + ); it('under a ?from= trail: ← and the path, each ancestor a link to its page', async () => { const trail = encodeURIComponent(JSON.stringify([{ o: LEAD, i: 'L-1', t: 'Mira Costa' }])); @@ -261,14 +276,14 @@ describe('the breadcrumb while the record is read (objectstack#35412)', () => { // bar (objectstack#35593), the crumb's own name until then. const crumbName = () => document.querySelector('[data-record-bar-title]:not([hidden]) h1')?.textContent - ?? screen.getByTestId('record-page-crumb').querySelector('[aria-current="page"]')?.textContent; + ?? document.querySelector('[data-record-page-title]')?.textContent; it('names the record by its object until the read lands, never by its id', async () => { const read = deferredRead('r-1'); mountPage(`/apps/${APP}/${LEAD}/record/r-1`, read.dataSource); await waitFor(() => expect(read.dataSource.findOne).toHaveBeenCalled(), { timeout: 5000 }); expect(crumbName()).toBe('Lead'); - expect(screen.getByTestId('record-page-crumb').textContent).not.toContain('#'); + expect(crumbName()).not.toContain('#'); read.answer(); await waitFor(() => expect(crumbName()).toBe('Record r-1')); }); @@ -326,7 +341,8 @@ describe('the pane\'s top bar names the record (objectstack#27524)', () => { , ); // objectstack#35593 — the record's header holds the pane's bar: its H1 is - // the bar's name, with no object crumb, counter or ↓ ↑ beside it. + // the bar's name. objectstack#35853 — the pane's navigation row draws ↑ ↓ + // and 「N of M · view」 over the list beside it. const paneTitle = () => document.querySelector('[data-record-bar-title] h1')?.textContent; await waitFor(() => expect(paneTitle()).toBe('Record r-1'), { timeout: 5000 }); expect(screen.queryByTestId('record-drawer-crumb')).toBeNull(); @@ -336,8 +352,9 @@ describe('the pane\'s top bar names the record (objectstack#27524)', () => { expect(document.querySelector('[data-page-header-trailing]')).toBeNull(); // The pane draws its own bar; the record inside draws none. expect(document.querySelectorAll('[data-record-top-bar]')).toHaveLength(1); - expect(document.querySelector('[data-record-top-bar-position]')).toBeNull(); - expect(screen.queryByRole('button', { name: 'Next record' })).toBeNull(); + expect(document.querySelector('[data-record-top-bar-position]')?.textContent).toBe('1 of 3'); + expect(document.querySelector('[data-record-top-bar-scope]')?.textContent).toBe('All leads'); + expect(screen.getByRole('button', { name: 'Next record' })).toBeTruthy(); // The step keys stay: j names the next record once its header draws. fireEvent.keyDown(document.body, { key: 'j' }); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.tsx b/ui/packages/app-shell/src/views/RecordDetailView.tsx index 97bb18fe291..c64498a00a4 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.tsx @@ -11,7 +11,7 @@ import { createElement, useState, useEffect, useLayoutEffect, useCallback, useContext, useMemo, useRef, type ReactElement } from 'react'; import { useParams, useNavigate, useLocation, useSearchParams, Link } from 'react-router-dom'; import { activityRowToFeedItem, composeImpersonatedActor, IMPERSONATED_ACTOR_FALLBACK, auditEntriesToFeedItems, bodyTableIdsOf, claimQueuedRecord, RECORD_PAGE_TIMELINE_PANEL, RECORD_TIMELINE_PANEL_MAX_ENTRIES, RecordFieldChangesContext, RecordFieldHistoryContext, RecordTimelineTotalContext, DefaultRecordPageContext, EMPTY_RELATED_ARRANGEMENT, InlineEditSaveBar, RecordBodyTablesContext, RecordMetaFooter, RecordPageColumns, buildDefaultPageColumns, buildDefaultPageSchema, extractMentions, isRefusedFeedRead, recordPageTierHasRightColumn, recordSitsInQueue, resolveTitleField, useQueueClaimOffered, useRecordEditable, useRecordPageTier } from '@object-ui/plugin-detail'; -import { Empty, EmptyTitle, EmptyDescription, Button, PageHeaderActions, PageHeaderPhoneContext, PageHeaderTrailingContext, PanelToggles, RecordHeaderBarContext, RecordHeaderStateContext, RecordTopBar, cn, useRecordStepKeys, type PanelToggleItem, type RecordHeaderBar, type RecordHeaderGroupParts, type RecordHeaderState, type RecordTopBarStepper } from '@object-ui/components'; +import { Empty, EmptyTitle, EmptyDescription, Button, PageHeaderActions, PageHeaderPhoneContext, PageHeaderTrailingContext, PanelToggles, RecordHeaderBarContext, RecordHeaderStateContext, RecordTopBar, RecordTopBarButton, cn, useRecordStepKeys, type PanelToggleItem, type RecordHeaderBar, type RecordHeaderGroupParts, type RecordHeaderState, type RecordTopBarStepper } from '@object-ui/components'; import { getIcon } from '../utils/getIcon.js'; import { isActingApprover } from '../utils/approvalDecisionFold.js'; import { useAuth, createAuthenticatedFetch } from '@object-ui/auth'; @@ -22,7 +22,7 @@ import type { AnsweredLoadFailure } from '@object-ui/react'; import { buildExpandFields, captureUpdateUndoData, recordDelete, resolveAffordance, resolveRecordIdParamSeed, userActionPredicates, withoutDeniedFields, type AffordanceGrantPrincipal, type SchemaLike } from '@object-ui/core'; import { toast } from 'sonner'; import { useRecordPresence, PresenceAvatars, isCommentAuthor } from '@object-ui/collaboration'; -import { Database, ArrowLeft, ChevronLeft, ChevronRight, Lock, AlertTriangle, RotateCw, Printer, FileText, CheckCircle2, Inbox, PanelRight } from 'lucide-react'; +import { Database, ArrowLeft, ChevronLeft, ChevronRight, Lock, AlertTriangle, RotateCw, Printer, FileText, CheckCircle2, Inbox, PanelRight, X } from 'lucide-react'; import { checkPageRecordPlacesComponent } from '@objectstack/spec/ui'; import { MetadataPanel, useMetadataInspector } from './MetadataInspector.js'; import { SkeletonDetail } from '../skeletons/index.js'; @@ -955,17 +955,17 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri }; }, [originFromState, location.search, appName]); // objectstack#27524, Target 7 — a page a list opened knows that list: its - // top bar steps the list's rows with the counter, ↓ ↑ and `j` / `k` (the - // arrow keys scroll the page). A page the row's ↗ opened also offers ⤡ - // 「Collapse to drawer」, and its object crumb returns to the list. The - // counter names the list's view (the origin's label). A record drawn in a - // pane has the pane's bar. + // top bar steps the list's rows with ↑ ↓ and `j` / `k` (the arrow keys + // scroll the page) and counts the record among the list's matched total + // (objectstack#35853: 「第 N 条,共 M 条 · 视图名」). The view's name and the + // bar's ✕ return to the list as it was left (objectstack#35854). A record + // drawn in a pane has the pane's bar. const pageReturn = useRecordPageReturn(embedded ? undefined : recordId); const pageStepper = useMemo( () => (pageReturn.stepper && originFromState?.label - ? { ...pageReturn.stepper, scope: originFromState.label } + ? { ...pageReturn.stepper, scope: originFromState.label, ...(pageReturn.toList ? { onScope: pageReturn.toList } : {}) } : pageReturn.stepper), - [pageReturn.stepper, originFromState?.label], + [pageReturn.stepper, pageReturn.toList, originFromState?.label], ); useRecordStepKeys(!embedded && !!pageStepper, pageStepper, { arrows: false }); // `language` is also the language a flow launch reads a refused write's @@ -5255,12 +5255,13 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri /> ) : null; - // objectstack#27524, Target 7 — the page's top bar: the frame controls in - // one 40 px row above the record header, which keeps the business actions. - // Left, the breadcrumb: under a `?from=` trail `←` and the path (each - // ancestor returns to its page), else 「对象 › 记录名」, the object returning - // to the list the page was opened from (or the object's list). Right, each - // only where it applies: the counter and ↓ ↑ (a list context), ⊟, ⤡. + // objectstack#27524, Target 7 / objectstack#35853 — the page's top bar, two + // rows on a desktop. The navigation row's left end: under a `?from=` trail + // `←` and the path (each ancestor returns to its page); from a list, ↑ ↓ + // and 「第 N 条,共 M 条 · 视图名」 (the bar draws them from the stepper); + // from neither, the object's name, returning to the object's list. Its + // right end: ✕. The record row: the record's name and tags, its buttons + // and ⊟. A phone keeps one row. const objectDefOf = (name: string) => objects.find((o: any) => o?.name === name); // objectstack#35593 — where the record header draws the record's name and // tags, after the crumb, and the 「/」 that separates the two once it does. @@ -5277,11 +5278,8 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri data-record-bar-title="" /> ); - const barTitleSeparator = barNamesRecord ? ( - - ) : null; const objectIconName = typeof (objectDef as any)?.icon === 'string' ? ((objectDef as any).icon as string) : undefined; - const objectIcon = barClaimed && objectIconName + const objectIcon = objectIconName ? createElement(getIcon(objectIconName), { className: 'h-4 w-4 shrink-0 text-muted-foreground', 'aria-hidden': true }) : null; const pageLeading = embedded ? null : pageTrail.length > 0 ? ( @@ -5314,19 +5312,15 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri ); })} - {objectDef ? servedObjectLabel(objectDef, language, objectLabel) : objectName} + {objectDef ? servedObjectLabel(objectDef, language, objectLabel) : objectName} - {barTitleSeparator} - {barTitleSlotEl} - ) : ( - <> + ) : pageStepper ? null : ( + ); + // objectstack#35853 — the bar's record row: the object's icon, then the + // record's name and tags as the record header draws them into the slot; + // until it holds the route's record, the bar's own name for it. + // Who else is on the record, and the managing package: on the page they + // stand in the record row after the title (objectstack#35745: the page + // starts right under the bar, so a badge floated over its top-right corner + // would sit on the tab row). Elsewhere they float, in `sharedChrome` below. + const recordBadges = ( + <> + {recordPresence.length > 0 && ( + + )} + {!inSetupApp && } + + ); + const pageRecordRow = embedded || phonePage ? undefined : ( + <> + {objectIcon} {!barNamesRecord && ( - <> -