From 2cb9ee3cdf691dd2120e703e5acccf9d65e1b500 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 15:26:36 +0000 Subject: [PATCH 01/12] =?UTF-8?q?feat(ui):=20two-row=20record=20header=20?= =?UTF-8?q?=E2=80=94=20navigation=20row=20and=20record=20row;=20action=20b?= =?UTF-8?q?udget=203=20with=20width=20folding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The record page and the side drawer draw a navigation row (back/trail, prev/next with the position in the list, the close button at the far right) above a record row (icon, title one size larger, actions). The header bar's authored-action budget returns to 3; actions that do not fit the bar's width fold into the overflow menu. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01Utp6Cbrs4FaLzn1HMmRDi1 --- .changeset/35853-record-header-two-rows.md | 19 ++ content/docs/ui/pages.mdx | 2 +- packages/spec/src/ui/component.zod.ts | 9 +- ...ovalsInboxPage.queueStepper-34586.test.tsx | 4 +- ...dDetailView.accessibleNames-12625.test.tsx | 9 +- ...dDetailView.headerMenuIcons-12529.test.tsx | 12 +- .../RecordDetailView.topBar-27524.test.tsx | 105 ++++++----- .../app-shell/src/views/RecordDetailView.tsx | 80 +++++---- .../recordDrawerStack-26679.test.tsx | 15 +- ...cordDrawerStack.rootStepper-26679.test.tsx | 8 +- .../recordPaneGroupScope-28461.test.tsx | 6 +- .../app-shell/src/views/recordDrawerStack.tsx | 65 ++++--- .../page-header-record-bar-35593.test.tsx | 65 +++++-- .../record-top-bar-two-rows-35853.test.tsx | 130 ++++++++++++++ .../src/custom/navigation-overlay.tsx | 17 +- .../components/src/custom/record-top-bar.tsx | 167 ++++++++++++++---- .../src/renderers/layout/containers.tsx | 80 +++++++-- 17 files changed, 589 insertions(+), 204 deletions(-) create mode 100644 .changeset/35853-record-header-two-rows.md create mode 100644 ui/packages/components/src/__tests__/record-top-bar-two-rows-35853.test.tsx diff --git a/.changeset/35853-record-header-two-rows.md b/.changeset/35853-record-header-two-rows.md new file mode 100644 index 00000000000..1b4f01dc4b7 --- /dev/null +++ b/.changeset/35853-record-header-two-rows.md @@ -0,0 +1,19 @@ +--- +'@objectstack/spec': patch +'@object-ui/components': minor +'@object-ui/app-shell': minor +--- + +feat(record-page): the record's header is two rows — navigation over the record — and shows up to three actions again + +Clause-②: no +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, linking to the object's list, and no ↑ ↓. ✕ 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, 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/ui/pages.mdx b/content/docs/ui/pages.mdx index 0851ac0d29b..9d13ea8da4e 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 (in a record page's header bar, actions that do not fit its 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/packages/spec/src/ui/component.zod.ts b/packages/spec/src/ui/component.zod.ts index 15d40c22973..d3f5229c2ec 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, actions that do not fit its 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/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/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 52ee7093769..be45fe1cb80 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 @@ -5253,12 +5253,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. @@ -5275,11 +5276,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 ? ( @@ -5312,19 +5310,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. + const pageRecordRow = embedded ? undefined : ( + <> + {objectIcon} {!barNamesRecord && ( - <> -