diff --git a/.changeset/36246-record-header-star.md b/.changeset/36246-record-header-star.md new file mode 100644 index 00000000000..6836d615431 --- /dev/null +++ b/.changeset/36246-record-header-star.md @@ -0,0 +1,12 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/components': patch +'@objectstack/spec': patch +--- + +feat(app-shell): the record's favorite star sits beside its name, and the header's `⋯` no longer holds "Add to favorites" + +Clause-②: no +Metadata-protocol: none + +The record page draws its favorite star right of the record's name, always visible: hollow until the record is a favorite, filled once it is, one press to toggle with no confirm. The full page, a drawer or split-pane preview, and a phone's record page all draw it, from the same favorite the sidebar's Favorites section reads, so nothing about the stored favorites or that section changes. The header's `⋯` menu drops its "Add to favorites" / "Remove from favorites" entry, so the page keeps one favorites control. On a phone the star keeps a 44px tap target, as the copy-id button beside it does. A print page, which draws no record header and so no star, keeps the entry in its chrome row's `⋯`. The `showStar` refusal in `@objectstack/spec` (the retired `page:header` key) now says what stays true: the console draws the record's star from the host's favorites toggle, never from metadata, so the key switched nothing; it no longer names the `⋯` menu as the favorites entry. diff --git a/content/docs/references/ui/component.mdx b/content/docs/references/ui/component.mdx index 22cc601e118..3c9b07926cb 100644 --- a/content/docs/references/ui/component.mdx +++ b/content/docs/references/ui/component.mdx @@ -1577,7 +1577,7 @@ An any-of group: `{ or: [rule, ...] }` matches a record when ANY of its rules ma | **actions** | `string[]` | optional | Action IDs the header draws, resolved against the actions declared on the page's object. An authored list is the whole set: an action that declares `record_header` (or `record_more`) in its `locations` but is not named here is not drawn, and a header with neither this key nor `placedActions: true` draws none of the object's actions. `placedActions: true` is the other way to say which actions the header draws (every one placed at `record_header` / `record_more`, read live), and the two are refused together. A named action that declares neither location renders nowhere. The host's own Edit / Share / Delete chrome is separate from this list. | | **placedActions** | `boolean` | optional | Draw every action of the page's object whose `locations` include `record_header` or `record_more`, read live from the object's metadata, in place of an authored `actions` list: an action added to the object later, by any package, is drawn without editing the page. Omit it, or set false, to keep the `actions` list as the whole set. Refused as `true` beside an authored `actions` list: keep one. | | **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. | +| **showStar** | `never` | optional | [REMOVED] `page:header` property `showStar` was removed in @objectstack/spec 18 (ADR-0087 D2) — the console draws the record's star from the host's favorites toggle, never from metadata, so the key switched nothing. Delete the key, whether it was `true` or `false`; the page draws the same star without it. Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand. | | **showCopyId** | `boolean` | optional (default: `true`) | Show the copy-record-id button beside the record title. Part of the record chrome — no effect when `recordChrome` is false. | | **maxVisible** | `integer` | optional | How many header actions render as inline buttons before the rest fold into the overflow menu. Renderer default when unset: 3 on every header. In a record page's header bar the number, authored or not, is an upper bound: actions that do not fit the bar's width fold as well, so a narrow drawer shows fewer. | | **mobileMaxVisible** | `integer` | optional | The `maxVisible` budget on mobile viewports. Renderer default when unset: 2 in a record page's bottom action bar on a phone, where the host's Edit counts as one, 1 on any other header. | diff --git a/packages/lint/src/validate-component-props.test.ts b/packages/lint/src/validate-component-props.test.ts index f2662bef0dc..2cc5a45c9bb 100644 --- a/packages/lint/src/validate-component-props.test.ts +++ b/packages/lint/src/validate-component-props.test.ts @@ -105,8 +105,8 @@ describe('validateComponentProps — undeclared keys', () => { }); // #23650 — `PageHeaderProps.showStar` is a retiredKey tombstone, the - // `breadcrumb` route one key over: the reference console draws no star, and - // the record's favorites entry is the header's ⋯ menu. It replaces the + // `breadcrumb` route one key over: the star follows the host's favorites + // toggle, never metadata. It replaces the // acceptance this file used to pin for `showStar: false` (#6776, below). it('refuses a retired page-header `showStar` as an error carrying the prescription, for `true` and `false`', () => { for (const showStar of [true, false]) { @@ -119,7 +119,7 @@ describe('validateComponentProps — undeclared keys', () => { expect(f.severity).toBe('error'); expect(f.path).toBe('pages[0].regions[0].components[0].properties.showStar'); expect(f.message).toContain('`page:header` property `showStar` was removed in @objectstack/spec 18'); - expect(f.message).toContain('the record\'s favorites entry is the header\'s ⋯ menu, and metadata does not control it'); + expect(f.message).toContain('the console draws the record\'s star from the host\'s favorites toggle, never from metadata'); } }); diff --git a/packages/spec/src/conversions/entries/18/page-header-show-star-removed.ts b/packages/spec/src/conversions/entries/18/page-header-show-star-removed.ts index b3748407e76..7e70e4f8158 100644 --- a/packages/spec/src/conversions/entries/18/page-header-show-star-removed.ts +++ b/packages/spec/src/conversions/entries/18/page-header-show-star-removed.ts @@ -19,21 +19,20 @@ import { isDict, stripKeys } from '../shared.js'; * enforce-or-remove; ruling record 6203775759, letter A: 「A 退役 showStar * (Recommended)」). * - * The key switched a star the reference console no longer draws. Since - * objectui#12427 the `page:header` record chip draws the follow star only - * where the host wires a favorites toggle into the record context - * (`onToggleFavorite`), and no reference host does: the record's favorites - * entry is the header's ⋯ overflow menu. `true` drew nothing and `false` hid - * nothing. The tombstone on `PageHeaderProps` refuses it for a live author: + * The key switched nothing. Since objectui#12427 the `page:header` record + * chip draws the follow star wherever the host wires a favorites toggle into + * the record context (`onToggleFavorite`), whatever the key says: the console + * draws the record's star from the host's favorites toggle, never from + * metadata. `true` and `false` draw the same star. The tombstone on `PageHeaderProps` refuses it for a live author: * `os validate`, `os build` and `os lint` refuse it as an `error` with the * prescription (the component-props gate, `@objectstack/lint`; the load path * keeps the open `properties` bag as written). * * **A delete of both values.** Neither changes what the reference console * draws, so there is no value to preserve and no rewrite target. The host - * hook is not the key: a third-party host of the published component library - * that wires `onToggleFavorite` keeps its star, and after the strip a header - * that said `false` shows it there as an absent key would. The D3 entry + * hook is not the key: any host of the published component library that wires + * `onToggleFavorite`, the console included, draws its star, and a header that + * said `false` shows it there as an absent key would. The D3 entry * `page-header-show-star-retired` records that. * * Who writes the key: nobody measured. No example app, skill or doc in this @@ -51,9 +50,8 @@ const pageHeaderShowStarRemoved: MetadataConversion = { retiredAfter: '17.7.0', surface: 'page.component.page:header.showStar', summary: - "page:header prop 'showStar' removed, whether 'true' or 'false' (the reference console draws no star " - + 'beside the record title: the record\'s favorites entry is the header\'s ⋯ menu, and metadata does ' - + 'not control it)', + "page:header prop 'showStar' removed, whether 'true' or 'false' (the console draws the record's star " + + 'from the host\'s favorites toggle, never from metadata, so the key switched nothing)', apply(stack, emit) { return mapPageComponents(stack, (component, path) => { if (component.type !== 'page:header') return component; diff --git a/packages/spec/src/migrations/entries/semantic/18.page-header-show-star-retired.ts b/packages/spec/src/migrations/entries/semantic/18.page-header-show-star-retired.ts index fdf40d6e327..450f59bf12b 100644 --- a/packages/spec/src/migrations/entries/semantic/18.page-header-show-star-retired.ts +++ b/packages/spec/src/migrations/entries/semantic/18.page-header-show-star-retired.ts @@ -5,23 +5,25 @@ import type { SemanticMigration } from '../../types.js'; // #23650 (ADR-0049 enforce-or-remove) — the D3 entry of the // `page-header-show-star-removed` family (one D3 entry per retirement family, // even when D2 is lossless). Registered key: `ui/PageHeaderProps:showStar`. -// The strip changes nothing the reference console draws; what it can change -// is a third-party host that wires its own favorites toggle. +// The strip changes nothing the reference console draws: the console draws +// the record's star from the host's favorites toggle, never from metadata. export const entry: SemanticMigration = { id: 'page-header-show-star-retired', surface: 'page.component.page:header.showStar — the follow star beside the record title', replacement: - 'Nothing: delete the key, whether it was `true` or `false`. The record\'s favorites entry is the ' - + 'header\'s ⋯ menu, and metadata does not control it.', + 'Nothing: delete the key, whether it was `true` or `false`. The console draws the record\'s star ' + + 'from the host\'s favorites toggle, never from metadata, so the page draws the same star without it.', reason: 'The D2 conversion `page-header-show-star-removed` deletes `showStar` from every page header, and ' - + 'nothing the reference console draws changes: its record chip draws the follow star only where ' - + 'the host wires a favorites toggle into the record context, and the console wires none, so ' - + '`true` drew nothing and `false` hid nothing. What the conversion cannot decide is a host of ' - + 'your own: if it wires that favorites toggle, the star now draws on every record header, a ' - + 'header that said `false` included, and hiding it there is the host\'s call, not the page\'s.', + + 'nothing the reference console draws changes: the console draws the record\'s star from the ' + + 'host\'s favorites toggle, never from metadata. Its record chip draws the star beside the record ' + + 'name wherever the host wires that toggle into the record context, and the console wires it on ' + + 'its record pages, so `true` and `false` draw the same star. A host of your own works the same ' + + 'way: the star draws where it wires the favorites toggle, a header that said `false` included, ' + + 'and hiding it there is the host\'s call, not the page\'s.', acceptanceCriteria: 'No page header carries `showStar`, and the props lint reports one with the prescription. Every ' - + 'record page shows the same header in the console as before the upgrade — title, copy-id ' - + 'button and actions — and the record\'s favorites entry is still in the header\'s ⋯ menu.', + + 'record page shows the same header in the console as before the strip — title, copy-id button, ' + + 'actions and the record\'s star beside the record name — and the header\'s ⋯ menu holds no ' + + 'favorites entry (only a print page, which draws no header, keeps one in its ⋯).', }; diff --git a/packages/spec/src/migrations/registry.ts.template b/packages/spec/src/migrations/registry.ts.template index 0a9603a8e0d..1c9e20a7114 100644 --- a/packages/spec/src/migrations/registry.ts.template +++ b/packages/spec/src/migrations/registry.ts.template @@ -2665,10 +2665,10 @@ const STEP18_RATIONALE: readonly RationaleFragment[] = [ order: 98, text: 'It also retires the page header\'s `showStar` switch (ADR-0049 enforce-or-remove): the ' - + 'reference console draws no star beside the record title — its record chip draws one only ' - + 'where the host wires a favorites toggle, and the console\'s favorites entry is the ' - + 'header\'s ⋯ menu — so the key switched nothing. The key is a retiredKey tombstone on ' - + '`PageHeaderProps`, beside `icon` and `breadcrumb`, and the D2 conversion ' + + 'console draws the record\'s star from the host\'s favorites toggle, never from metadata — ' + + 'its record chip draws the star beside the record name wherever the host wires that toggle, ' + + 'and the console wires it on its record pages — so the key switched nothing. The key is a ' + + 'retiredKey tombstone on `PageHeaderProps`, beside `icon` and `breadcrumb`, and the D2 conversion ' + '`page-header-show-star-removed` strips it from every `page:header`, `true` and `false` ' + 'alike, retired from the load path. Its D3 record is the semantic entry ' + '`page-header-show-star-retired`. The host hook is not part of it: a host that wires the ' diff --git a/packages/spec/src/ui/component.zod.ts b/packages/spec/src/ui/component.zod.ts index be958fa3c15..fbe14df674c 100644 --- a/packages/spec/src/ui/component.zod.ts +++ b/packages/spec/src/ui/component.zod.ts @@ -779,8 +779,8 @@ export const PageHeaderProps = strictObject({ * * ON (the default) the header carries the **record chrome**: the title * renders as a record chip with the copy-record-id button beside it (the - * follow star draws there only where a host wires a favorites toggle; the - * reference console's favorites entry is the header's ⋯ menu). OFF it falls back to a bare heading — one title line and + * follow star draws there only where a host wires a favorites toggle, as the + * reference console does on its record pages). OFF it falls back to a bare heading — one title line and * nothing record-shaped — which is what a dashboard or a landing page wants, * since there is no record for the chip to describe. * @@ -801,11 +801,12 @@ export const PageHeaderProps = strictObject({ * the way `breadcrumb` above left this row; ruling record 6203775759, * letter A). * - * A switch for a star the reference console no longer draws. Since - * objectui#12427 the record chip draws the follow star only where the HOST - * wires a favorites toggle into the record context (`onToggleFavorite`), - * and no reference host does: the record's favorites entry is the header's - * ⋯ overflow menu. So `showStar: true` (the default) drew nothing and + * A switch metadata never had a say in. Since objectui#12427 the record chip + * draws the follow star only where the HOST wires a favorites toggle into + * the record context (`onToggleFavorite`); when the key was retired no + * reference host did, and since #36246 the reference console wires it on + * its record pages, beside the record's name. Either way the star follows + * the host's toggle, so `showStar: true` (the default) drew nothing and * `showStar: false` hid nothing. No example app, skill or doc authored it. * * The host hook stays: objectui's `RecordContextValue.onToggleFavorite` is a @@ -817,9 +818,8 @@ export const PageHeaderProps = strictObject({ */ showStar: retiredKey( '`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. ' + + 'the console draws the record\'s star from the host\'s favorites toggle, never from metadata, so the key switched nothing. ' + + 'Delete the key, whether it was `true` or `false`; the page draws the same star without it. ' + 'Run `os migrate meta --from 17` to list the mechanical edits for existing sources; `--write` applies the ones it can prove, and you apply the rest by hand.', ), /** diff --git a/packages/spec/src/ui/page-header-show-star-retirement.test.ts b/packages/spec/src/ui/page-header-show-star-retirement.test.ts index 4f754bf96cb..39d6885548f 100644 --- a/packages/spec/src/ui/page-header-show-star-retirement.test.ts +++ b/packages/spec/src/ui/page-header-show-star-retirement.test.ts @@ -11,7 +11,9 @@ * record context (`onToggleFavorite`), and no reference host does — the * console's favorites entry is the header's ⋯ overflow menu. So `true` (the * default) drew nothing and `false` hid nothing. No producer writes the key in - * this repo or in objectui's apps and examples. + * this repo or in objectui's apps and examples. Since objectstack#36246 the + * console wires that toggle on its record pages, and the star still answers + * the host's toggle, never the key. * * Bookkeeping shapes, pinned below: * 1. A `retiredKey()` tombstone on `PageHeaderProps`, a `strictObject` — the @@ -58,7 +60,7 @@ const REGISTERED_KEY = 'ui/PageHeaderProps:showStar'; // Unanchored, because a thrown `ZodError`'s message is the JSON of its issues; // the key-first house convention is asserted on the issue message itself. const PRESCRIPTION = - /`page:header` property `showStar` was removed in @objectstack\/spec 18 \(ADR-0087 D2\) — the reference console draws no star beside the record title.*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`.*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\./s; + /`page:header` property `showStar` was removed in @objectstack\/spec 18 \(ADR-0087 D2\) — the console draws the record's star from the host's favorites toggle, never from metadata, so the key switched nothing\..*Delete the key, whether it was `true` or `false`.*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\./s; /** A page header's live keys — what an author commonly writes, not the retired one. */ const HEADER = { title: 'Account', subtitle: '{industry}', showCopyId: false, actions: ['log_call'] } as const; diff --git a/ui/packages/app-shell/src/views/RecordDetailView.favoritesEntry-12427.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.favoritesEntry-12427.test.tsx index 8f34de4e2ef..bd24859d86e 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.favoritesEntry-12427.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.favoritesEntry-12427.test.tsx @@ -7,20 +7,20 @@ */ /** - * objectui#12427: the record page's favorites entry is in the header's `⋯` - * overflow, ahead of Share. + * objectstack#36246: the record's favorites control is the star beside its + * name, as Attio draws it (maintainer: 「以 attio 为准」). It is always drawn, + * hollow until the record is a favorite and filled once it is, and one press + * toggles it with no confirm. The header's `⋯` holds no favorites entry, so + * the page keeps one control. Every face `page:header` draws carries it: the + * full page's bar, a drawer or pane (`embedded`), and a phone's header. * - * A record is never a navigation entry, so the entry toggles the `record:` - * favorite, which the sidebar draws in its Favorites section at the top. It - * reads "Add to favorites", then "Remove from favorites" once the record is - * one. + * A record is never a navigation entry, so the star toggles the `record:` + * favorite, which the sidebar draws in its Favorites section at the top; the + * stored entry is the one the `⋯` entry of objectui#12427 wrote. * - * It is the page's ONE favorites control: the record header draws no star. - * This page no longer hands the record context an `onToggleFavorite`, and the - * `page:header` chrome draws its star only for a host that does (the - * components pin `page-header-star-host-toggle-12427`). Updated deliberately - * by the record-star remainder of objectui#12427: the header star that sat - * beside this entry is gone, in both favorite states. + * Updated deliberately by objectstack#36246: this file pinned the opposite + * (the `⋯` entry as the one control, no header star), objectui#12427's + * placement, which the maintainer's ruling reverses. * * Harness: the `RecordDetailView.deleteConfirmDialog-11001` mount (the real * record page under a real `I18nProvider` and a metadata context), plus the @@ -101,7 +101,7 @@ const METADATA = { const STORE_KEY = 'objectui-favorites'; const stored = (): FavoriteItem[] => JSON.parse(localStorage.getItem(STORE_KEY) ?? '[]'); -async function mountRecordPage() { +async function mountRecordPage(opts: { embedded?: boolean } = {}) { const dataSource = { find: vi.fn(async () => ({ data: [] })), findOne: vi.fn(async () => ({ id: RECORD_ID, name: 'Intro call' })), @@ -117,7 +117,20 @@ async function mountRecordPage() { {}} />} + element={ + opts.embedded ? ( + {}} + objectNameOverride={OBJECT_NAME} + recordIdOverride={RECORD_ID} + embedded + /> + ) : ( + {}} /> + ) + } /> @@ -137,9 +150,14 @@ function headerStars(): HTMLElement[] { ]; } +/** Whether a star draws filled: the chip fills its icon once the record is a favorite. */ +function isFilled(star: HTMLElement): boolean { + return star.querySelector('svg')?.getAttribute('class')?.split(/\s+/).includes('fill-yellow-400') ?? false; +} + /** Opens the header's overflow and returns its entries' text. */ async function openOverflow(): Promise { - const trigger = screen.getByRole('button', { name: 'More actions' }); + const [trigger] = screen.getAllByRole('button', { name: 'More actions' }); fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false, pointerType: 'mouse' }); await waitFor(() => expect(screen.getByRole('menu')).toBeInTheDocument()); return screen.getAllByRole('menuitem').map((el) => (el.textContent ?? '').trim()); @@ -164,36 +182,30 @@ afterEach(() => { vi.clearAllMocks(); }); -describe('record page: the favorites entry is in the overflow, ahead of Share (objectui#12427)', () => { - it('the overflow leads with Add to favorites, then Share — after the Refresh that heads it', async () => { - await mountRecordPage(); - const items = await openOverflow(); - // objectstack#27055: the host's Refresh is the ⋯'s first item. - expect(items.indexOf('Refresh')).toBe(0); - expect(items.indexOf('Add to favorites')).toBe(1); - expect(items.indexOf('Share')).toBe(2); - }); - - it('the record header draws no star, so the overflow entry is the one favorites control', async () => { +describe('record page: the favorite star beside the record name, none in the ⋯ (objectstack#36246)', () => { + it('the star sits in the name\'s row, hollow, and the ⋯ holds no favorites entry', async () => { await mountRecordPage(); - // The record chip is drawn (its copy-id button sits in the star's row), - // so "no star" cannot pass on a header that drew no chip at all. - await waitFor(() => expect(screen.getByRole('button', { name: 'Copy record ID' })).toBeInTheDocument()); - expect(headerStars()).toHaveLength(0); + const star = await waitFor(() => { + const [only, ...rest] = headerStars(); + expect(rest).toHaveLength(0); + expect(only).toBeTruthy(); + return only; + }); + expect([star.getAttribute('aria-label'), star.getAttribute('aria-pressed')]).toEqual(['Add to favorites', 'false']); + expect(isFilled(star)).toBe(false); + // Beside the record's name: the chip row that holds the H1. + const title = screen.getByRole('heading', { level: 1, name: 'Intro call' }); + expect(title.parentElement!.contains(star)).toBe(true); const items = await openOverflow(); - expect(items.filter((text) => /favorites$/.test(text))).toEqual(['Add to favorites']); - - // Still none once the record is a favorite. - fireEvent.click(screen.getByRole('menuitem', { name: 'Add to favorites' })); - await waitFor(() => expect(stored()).toHaveLength(1)); - expect(headerStars()).toHaveLength(0); + // CONTROL: the ⋯ is open and holds the system group. + expect(items).toContain('Share'); + expect(items.filter((text) => /favorites$/.test(text))).toEqual([]); }); - it('choosing it writes the record favorite, and the entry then reads Remove from favorites', async () => { + it('one press makes the record a favorite and fills the star; a second press removes it', async () => { await mountRecordPage(); - await openOverflow(); - fireEvent.click(screen.getByRole('menuitem', { name: 'Add to favorites' })); + fireEvent.click(await screen.findByRole('button', { name: 'Add to favorites' })); await waitFor(() => expect(stored()).toHaveLength(1)); const [favorite] = stored(); @@ -202,12 +214,98 @@ describe('record page: the favorites entry is in the overflow, ahead of Share (o 'record', RECORD_PATH, ]); + const filled = await screen.findByRole('button', { name: 'Remove from favorites' }); + expect(filled.getAttribute('aria-pressed')).toBe('true'); + expect(isFilled(filled)).toBe(true); + expect(headerStars()).toHaveLength(1); + + fireEvent.click(filled); + await waitFor(() => expect(stored()).toHaveLength(0)); + const hollow = await screen.findByRole('button', { name: 'Add to favorites' }); + expect(hollow.getAttribute('aria-pressed')).toBe('false'); + expect(isFilled(hollow)).toBe(false); + }); - // The header re-derives its system actions on the next render, so the - // overflow's first action entry (after Refresh) now offers the way back. - await waitFor(() => - expect((screen.getAllByRole('menuitem')[1].textContent ?? '').trim()).toBe('Remove from favorites'), + it('a record already a favorite (a reload) opens with the star filled', async () => { + localStorage.setItem( + STORE_KEY, + JSON.stringify([ + { + id: `record:${OBJECT_NAME}:${RECORD_ID}`, + label: 'Intro call', + href: RECORD_PATH, + type: 'record', + favoritedAt: new Date(0).toISOString(), + }, + ]), ); + await mountRecordPage(); + const star = await screen.findByRole('button', { name: 'Remove from favorites' }); + expect(star.getAttribute('aria-pressed')).toBe('true'); + expect(isFilled(star)).toBe(true); + }); + + it('a drawer or pane (embedded) draws the same star, with the same state', async () => { + localStorage.setItem( + STORE_KEY, + JSON.stringify([ + { + id: `record:${OBJECT_NAME}:${RECORD_ID}`, + label: 'Intro call', + href: RECORD_PATH, + type: 'record', + favoritedAt: new Date(0).toISOString(), + }, + ]), + ); + await mountRecordPage({ embedded: true }); + const star = await waitFor(() => { + const [only, ...rest] = headerStars(); + expect(rest).toHaveLength(0); + expect(only).toBeTruthy(); + return only; + }); + expect([star.getAttribute('aria-label'), star.getAttribute('aria-pressed')]).toEqual(['Remove from favorites', 'true']); + const title = screen.getByRole('heading', { level: 1, name: 'Intro call' }); + expect(title.parentElement!.contains(star)).toBe(true); + + fireEvent.click(star); + await waitFor(() => expect(stored()).toHaveLength(0)); + expect((await screen.findByRole('button', { name: 'Add to favorites' })).getAttribute('aria-pressed')).toBe('false'); + const items = await openOverflow(); + expect(items).toContain('Share'); + expect(items.filter((text) => /favorites$/.test(text))).toEqual([]); + }); + + it('a phone draws the star beside the name, and its bottom bar\'s ⋯ holds no favorites entry', async () => { + Object.defineProperty(window, 'innerWidth', { value: 390, configurable: true, writable: true }); + const measure = HTMLElement.prototype.getBoundingClientRect; + vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (this: HTMLElement) { + if (!this.hasAttribute('data-record-page-root')) return measure.call(this); + return { x: 0, y: 0, top: 0, left: 0, right: 390, bottom: 800, width: 390, height: 800, toJSON: () => ({}) } as DOMRect; + }); + try { + await mountRecordPage(); + // CONTROL: the phone face is drawn — its bottom bar holds the actions. + await waitFor(() => expect(document.querySelector('[data-record-action-bar] [role="toolbar"]')).toBeTruthy()); + const star = await waitFor(() => { + const [only, ...rest] = headerStars(); + expect(rest).toHaveLength(0); + expect(only).toBeTruthy(); + return only; + }); + const title = screen.getByRole('heading', { level: 1, name: 'Intro call' }); + expect(title.parentElement!.contains(star)).toBe(true); + fireEvent.click(star); + await waitFor(() => expect(stored()).toHaveLength(1)); + + const items = await openOverflow(); + expect(items).toContain('Share'); + expect(items.filter((text) => /favorites$/.test(text))).toEqual([]); + } finally { + vi.restoreAllMocks(); + Object.defineProperty(window, 'innerWidth', { value: 1024, configurable: true, writable: true }); + } }); }); 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 7017d38c5f4..b76e583c90f 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 @@ -7,8 +7,9 @@ */ /** - * objectui#12529: the record header's system entries (Edit, favorites, Share, - * Delete) declare icons through the same `icon` key the app's actions use, so + * objectui#12529: the record header's system entries (Edit, Share, Delete; + * favorites is the star beside the name since objectstack#36246) declare + * icons through the same `icon` key the app's actions use, so * the `⋯` menu draws one kind of row; Delete is last, behind a separator. * * objectui#12617 replaced this file's third rule: Edit no longer folds into @@ -183,13 +184,14 @@ afterEach(() => { }); describe('record header: iconed system entries, Delete set apart in the ⋯, Edit a labelled button in the row (objectui#12529, objectui#12617)', () => { - it('each system entry carries its icon: Edit in the row, the other three in the ⋯', async () => { + it('each system entry carries its icon: Edit in the row, Share and Delete in the ⋯', async () => { await mountRecordPage(FULL_ROW); const edit = screen.getByRole('button', { name: 'Edit' }); await waitFor(() => expect(edit.querySelector('svg.lucide-pencil')).not.toBeNull()); const menu = await openOverflow(); + // The favorites control is the star beside the record's name + // (objectstack#36246), not a ⋯ entry. const expected: Record = { - 'Add to favorites': 'lucide-star', Share: 'lucide-share', Delete: 'lucide-trash', }; @@ -206,7 +208,7 @@ describe('record header: iconed system entries, Delete set apart in the ⋯, Edi // 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']); + expect(menuRows(menu)).toEqual(['Refresh', '---', '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 () => { @@ -238,6 +240,6 @@ describe('record header: iconed system entries, Delete set apart in the ⋯, Edi // The ⋯ then holds only the menu-pinned system entries. const menu = await openOverflow(); // The host's Refresh leads the ⋯, set apart (objectstack#27055). - expect(menuRows(menu)).toEqual(['Refresh', '---', 'Add to favorites', 'Share', '---', 'Delete']); + expect(menuRows(menu)).toEqual(['Refresh', '---', 'Share', '---', 'Delete']); }); }); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.tsx b/ui/packages/app-shell/src/views/RecordDetailView.tsx index d3e66ad6f39..809b659044f 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.tsx @@ -277,6 +277,15 @@ function recordPagePlacesNoComponent(page: Parameters - {/* No `isFavorite` / `onToggleFavorite` here (objectui#12427): the - record's favorites entry is the `sys_favorite` item in the header's - `⋯` overflow, and the `page:header` chrome draws its star only for - a host that wires `onToggleFavorite`, so this page draws none. */} {/* objectui#2407 P2 — ONE record-level inline-edit session spanning the highlights strip AND the details body (both descend from this provider), committed together by the single diff --git a/ui/packages/components/src/__tests__/page-header-star-host-toggle-12427.test.tsx b/ui/packages/components/src/__tests__/page-header-star-host-toggle-12427.test.tsx index c4066b12539..c73cb156e49 100644 --- a/ui/packages/components/src/__tests__/page-header-star-host-toggle-12427.test.tsx +++ b/ui/packages/components/src/__tests__/page-header-star-host-toggle-12427.test.tsx @@ -32,6 +32,9 @@ import { ComponentRegistry } from '@object-ui/core'; // Registers every renderer at module scope, not in a hook // (object-ui/no-dynamic-import-in-test-hook, objectui#3010). import '../renderers'; +// `page`'s react-page loads it with a dynamic import; paid at collection, not +// inside a case's clocked window (check:test-source-alias). +import '@object-ui/react-runtime'; afterEach(() => { cleanup(); @@ -106,6 +109,17 @@ describe('page:header record chrome: the favorite star draws only where the host expect(onToggleFavorite).toHaveBeenCalledTimes(1); }); + it('the star keeps a 44px tap target on a phone, as the copy-id button beside it does (objectstack#36246)', () => { + const { header } = renderHeader({ isFavorite: false, onToggleFavorite: () => {} }); + const [star] = stars(header); + const copyId = header.querySelector('button[aria-label="Copy record ID"]')!; + for (const cls of ['min-h-[44px]', 'min-w-[44px]', 'sm:min-h-0', 'sm:min-w-0']) { + // CONTROL: the copy-id button carries the same phone target. + expect(copyId.classList.contains(cls), `copy-id ${cls}`).toBe(true); + expect(star.classList.contains(cls), `star ${cls}`).toBe(true); + } + }); + it('CONTROL: the star mirrors the host state', () => { const { header } = renderHeader({ isFavorite: true, onToggleFavorite: () => {} }); const [star] = stars(header); diff --git a/ui/packages/components/src/custom/RecordTitleChip.tsx b/ui/packages/components/src/custom/RecordTitleChip.tsx index 8991b693ae8..4b9970135bf 100644 --- a/ui/packages/components/src/custom/RecordTitleChip.tsx +++ b/ui/packages/components/src/custom/RecordTitleChip.tsx @@ -182,7 +182,8 @@ export const RecordTitleChip: React.FC = ({