From b37d813a5f9d6dc69eb40cfbd7b19f21877c07d1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 23:31:37 +0000 Subject: [PATCH] =?UTF-8?q?fix(nightly):=20green=20the=20showcase=20live?= =?UTF-8?q?=20tiers=20on=20main=20=E2=80=94=20the=20currency=20picker=20re?= =?UTF-8?q?ads=20in=20a=20form=20host,=20and=20four=20specs=20read=20the?= =?UTF-8?q?=20product=20as=20merged?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The New Invoice line grid read the header's currency picker as empty, so a home-currency invoice withheld a picked product's price; the picker's trigger now carries its code and bubbles a change. Three specs and one smoke case pinned surfaces that moved: the sidebar's docking model, the record page's sectioned face at 1280 px, the collapsed System information footer and the retired summary rail. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01JQwxbanvK21nJKgGjvE9XL --- .changeset/36321-currency-picker-form-read.md | 9 +++ .../app-showcase/e2e/detail-shapes.spec.ts | 37 ++++++---- ui/e2e/live/inline-edit-polish-2572.spec.ts | 20 ++++-- .../live/phone-nav-drawer-back-29131.spec.ts | 17 +++-- ...rency-code-picker-form-read-36321.test.tsx | 71 +++++++++++++++++++ .../src/custom/currency-code-picker.tsx | 18 +++++ 6 files changed, 146 insertions(+), 26 deletions(-) create mode 100644 .changeset/36321-currency-picker-form-read.md create mode 100644 ui/packages/components/src/__tests__/currency-code-picker-form-read-36321.test.tsx diff --git a/.changeset/36321-currency-picker-form-read.md b/.changeset/36321-currency-picker-form-read.md new file mode 100644 index 00000000000..9e6d7693b02 --- /dev/null +++ b/.changeset/36321-currency-picker-form-read.md @@ -0,0 +1,9 @@ +--- +'@object-ui/components': patch +--- + +fix(components): a New Invoice in the home currency fills a picked product's price on its line again + +Clause-②: no + +The currency code picker's trigger now carries the selected code as its `value`, and a changed code bubbles a `change` event from it, as a native select does. The master-detail form reads its header's live values off the header's named elements, and read this one as empty: since the line grid withholds a picked amount from a line whose currency it cannot tell (objectstack#36249), a New Invoice in the home currency left Unit Price empty with the note "no currency is chosen here yet". The grid now reads the header's code once the header has been edited, and reads a picked code when it is picked. A line picked before any header edit still withholds the price and says so. diff --git a/examples/app-showcase/e2e/detail-shapes.spec.ts b/examples/app-showcase/e2e/detail-shapes.spec.ts index 8e966126eae..b0aa0123caa 100644 --- a/examples/app-showcase/e2e/detail-shapes.spec.ts +++ b/examples/app-showcase/e2e/detail-shapes.spec.ts @@ -21,9 +21,9 @@ import { test, expect } from '@playwright/test'; * one-column stack tier (objectstack#27524): a * `relatedList: 'primary'` list is a body table in the * details (objectstack#27055, Target 8) and takes no tab; - * the rest are tabs of the tab row (objectstack#35595), - * and one with records is a card of the 概览 tab's rail - * below the details (objectstack#35596) + * the rest are tabs of the tab row (objectstack#35595); + * the 概览 tab's rail that summarized them is retired + * (objectstack#35890), so the case opens the Contacts tab * * Runs against the console the backend serves at /_console (baseURL from * playwright.config.ts; storageState carries the admin session). The @@ -170,8 +170,8 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({ // The synthesized record page lays itself out by the width of the view it // occupies, by one rule (objectstack#26678, objectstack#27524): details | // the right column from `RECORD_PAGE_TWO_COLUMN_MIN_WIDTH` (760 px, - // `@object-ui/plugin-detail`), and ONE column below it — the details, then - // the 概览 tab's rail. The tab row (objectstack#35595) is drawn in every + // `@object-ui/plugin-detail`), and ONE column below it — the details on + // the tab row's first tab. The tab row (objectstack#35595) is drawn in every // tier. The case stays in that stack tier on purpose: the column tiers are // what every other page of this smoke draws at the Desktop Chrome viewport, // and the stack is also what the split pane (720 px) and a phone draw. @@ -207,7 +207,9 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({ await expect(page.locator(HIGHLIGHT_STRIP)).toHaveCount(0); await expect(page.locator(stageTag('status')).first()).toBeVisible(); - // One column: the details, then the rail. The tab row opens on 概览. + // One column, on the tab row, which opens on its first tab (详情 / Details, + // `overview`). The right summary rail is retired in every tier + // (objectstack#35890): the other related lists are the row's tabs. await expect(page.locator('[data-record-page-tier]')).toHaveAttribute('data-record-page-tier', 'stack'); await expect(page.locator('[data-record-columns]')).toHaveAttribute('data-record-columns-shown', 'details'); await expect(page.locator('[data-record-tab="overview"]')).toHaveAttribute('aria-selected', 'true'); @@ -216,8 +218,7 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({ // them (objectstack#27055, Target 8): Invoices and Projects are // `relatedList: 'primary'` (CORE relationships), so each is a body table in // the details, with its rows read at open, and takes no tab of its own; the - // rest of Contoso's lists (Contacts and the Field Zoo lookups) are tabs, and - // one with records is a card of the rail (objectstack#35596). + // rest of Contoso's lists (Contacts and the Field Zoo lookups) are tabs. // CONTROL for the absence below: an ordinary list's tab is drawn under the // same `OBJECT.FIELD` id, so a renamed id scheme reds here, not silently. await expect(page.locator('[data-record-tab="showcase_contact.account"]')).toHaveCount(1); @@ -231,8 +232,6 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({ .filter({ has: page.getByRole('columnheader', { name: 'Project Name' }) }); await expect(invoicesTable.getByRole('cell', { name: 'INV-1002', exact: true })).toBeVisible(); await expect(projectsTable.getByRole('cell', { name: 'Data Platform', exact: true })).toBeVisible(); - const rightColumn = page.locator('[data-record-column="right"]'); - await expect(rightColumn.getByRole('region', { name: /^(Invoices|Projects)$/ })).toHaveCount(0); // Contoso's own groups render in the details (ADR-0085 §5), its highlighted // fields among their members. @@ -244,15 +243,23 @@ test('related-heavy: body tables, the tab row and the rail on Contoso', async ({ await expect(details.getByText('$25,000,000', { exact: false }).first()).toBeVisible(); const footer = page.locator('[data-testid="record-meta-footer"]'); await expect(footer).toBeVisible(); + // On the field list the footer is a "System information" section that + // starts collapsed (objectstack#36147): open it, then read its rows + // (objectstack#36321). + const systemInfo = footer.getByRole('button', { name: 'System information' }); + await systemInfo.click(); + await expect(systemInfo).toHaveAttribute('aria-expanded', 'true'); const footerText = (await footer.innerText()).replace(/\s+/g, ' '); expect(footerText, 'footer dangles "Created by" without an actor').not.toMatch(/Created by/); expect(footerText).toMatch(/Created/); - // The rail's Contacts card summarizes the Contacts tab: its first rows, - // Contoso's seeded contacts among them. - const contactsCard = rightColumn.getByRole('region', { name: 'Contacts', exact: true }); - await contactsCard.scrollIntoViewIfNeeded(); - await expect(contactsCard.locator('[data-record-summary-row]').filter({ hasText: 'Carl Fox' })).toBeVisible(); + // Contoso's contacts are the Contacts tab, where the retired rail's card + // summarized them (objectstack#35890, objectstack#36321): the tab lists + // Contoso's seeded contacts. + const contactsTab = page.locator('[data-record-tab="showcase_contact.account"]'); + await contactsTab.click(); + await expect(contactsTab).toHaveAttribute('aria-selected', 'true'); + await expect(page.getByRole('tabpanel').getByText('Carl Fox', { exact: true }).first()).toBeVisible(); expect(errors, 'uncaught page errors on related-heavy detail').toEqual([]); }); diff --git a/ui/e2e/live/inline-edit-polish-2572.spec.ts b/ui/e2e/live/inline-edit-polish-2572.spec.ts index 4659c62a261..76654b8739f 100644 --- a/ui/e2e/live/inline-edit-polish-2572.spec.ts +++ b/ui/e2e/live/inline-edit-polish-2572.spec.ts @@ -56,9 +56,15 @@ const REPO_ROOT = decodeURIComponent(new URL(import.meta.url).pathname) .slice(0, -SELF_DEPTH_BELOW_REPO_ROOT) .join('/'); -// The record page's field list enters edit on a click of the value -// (objectstack#36147); the value carries this title. -const EDIT_HINT = 'Click to edit'; +// The shared inline-edit session this file pins is entered by a double-click +// on a value of the record page's sectioned face, which carries this title. +// That is the face at this config's 1280 px window, where the sidebar now +// starts expanded (objectstack#36112). The field-list face (the pinned left +// column on a wider page, objectstack#36147) titles a value "Click to edit", +// and a click there edits that one field in place and saves it alone, with no +// session and no save bar (objectstack#36475): not what this file pins +// (objectstack#36321). +const EDIT_HINT = 'Double-click to edit'; function authToken(): string { const state = JSON.parse(readFileSync(join(REPO_ROOT, 'e2e/live/.auth/state.json'), 'utf8')); @@ -119,12 +125,12 @@ test('record inline-edit polish (#2572) — showcase Project end-to-end', async if (/\/api\/v1\/data\/showcase_account\/[^/?]+/.test(r.url())) accountHydrations.push(r.url()); }); - // ── Enter the shared inline-edit session (click a details-body field). ── + // ── Enter the shared inline-edit session (double-click a details-body field). ── const spentGroup = page .locator('div.group') .filter({ has: page.getByText('Spent', { exact: true }) }) .last(); - await spentGroup.locator(`[title="${EDIT_HINT}"]`).click(); + await spentGroup.locator(`[title="${EDIT_HINT}"]`).dblclick(); const saveBtn = page.getByRole('button', { name: 'Save', exact: true }); await expect(saveBtn, 'save bar appears once the session is live').toBeVisible(); @@ -151,7 +157,7 @@ test('record inline-edit polish (#2572) — showcase Project end-to-end', async .locator('div.group') .filter({ has: page.getByText('Budget', { exact: true }) }) .last(); - await budgetGroup.locator(`[title="${EDIT_HINT}"]`).click(); + await budgetGroup.locator(`[title="${EDIT_HINT}"]`).dblclick(); await expect(saveBtn).toBeVisible(); const budgetInput2 = page.locator('input[type="number"][min="0"][step="0.01"]').first(); // Above the flow's 500k decision edge, so approving `manager_review` routes @@ -222,7 +228,7 @@ test('record inline-edit polish (#2572) — showcase Project end-to-end', async await expect(approvalTag, 'the header names the pending approval').toBeVisible(); await expect(approvalTag, 'an unlocked approval step does not lock the tag').not.toHaveAttribute('data-record-approval-locked'); // A double-click on the budget still opens an inline-edit session. - await budgetGroupOnPage().locator(`[title="${EDIT_HINT}"]`).click(); + await budgetGroupOnPage().locator(`[title="${EDIT_HINT}"]`).dblclick(); await expect(saveBtn, 'inline editing stays live during an unlocked approval').toBeVisible(); await page.keyboard.press('Escape'); await expect(saveBtn).toBeHidden(); diff --git a/ui/e2e/live/phone-nav-drawer-back-29131.spec.ts b/ui/e2e/live/phone-nav-drawer-back-29131.spec.ts index 2423a18bc78..491acd38660 100644 --- a/ui/e2e/live/phone-nav-drawer-back-29131.spec.ts +++ b/ui/e2e/live/phone-nav-drawer-back-29131.spec.ts @@ -26,7 +26,9 @@ import { test, expect, type Page } from '@playwright/test'; const APP = 'com.example.showcase'; const LIST = `/apps/${APP}/showcase_task`; const DRAWER = '[data-sidebar="sidebar"][data-mobile="true"]'; -const TRIGGER = 'button[data-sidebar="trigger"]'; +/** The desktop sidebar's collapse button, and the page header's expand button (objectstack#36112). */ +const COLLAPSE = '[data-testid="sidebar-collapse"]'; +const EXPAND = '[data-testid="shell-sidebar-expand"]'; /** On a phone list the app bar's 「‹」, there once the page is drawn. */ const PHONE_BACK = '[data-testid="app-bar-phone-home"]'; const FLAG = '__navDrawerOpen'; @@ -142,13 +144,20 @@ for (const width of [375, 390]) { test.describe('desktop sidebar', () => { test.use({ viewport: { width: 1280, height: 800 } }); + // From 1280 px the sidebar starts expanded, and its collapse button and the + // page header's expand button are each drawn only while they act + // (objectstack#36112); the collapsed sidebar's own button stays in the DOM, + // off the screen. So the two presses are the visible control each time, by + // its test id, never the first trigger in the DOM (objectstack#36321). test('CONTROL — opening and closing the sidebar writes no history entry', async ({ page }) => { - await openList(page, TRIGGER); + await openList(page, COLLAPSE); const url = page.url(); const length = await historyLength(page); - await page.locator(TRIGGER).first().click(); - await page.locator(TRIGGER).first().click(); + await page.locator(COLLAPSE).click(); + await expect(page.locator(EXPAND)).toBeVisible(); + await page.locator(EXPAND).click(); + await expect(page.locator(COLLAPSE)).toBeInViewport(); expect(await historyLength(page)).toBe(length); expect(page.url()).toBe(url); diff --git a/ui/packages/components/src/__tests__/currency-code-picker-form-read-36321.test.tsx b/ui/packages/components/src/__tests__/currency-code-picker-form-read-36321.test.tsx new file mode 100644 index 00000000000..6837c394174 --- /dev/null +++ b/ui/packages/components/src/__tests__/currency-code-picker-form-read-36321.test.tsx @@ -0,0 +1,71 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * objectstack#36321 — the currency code picker is readable by a form host that + * reads its fields off the DOM. + * + * The master-detail form's line grid reads the header's live values from the + * header's named elements and re-reads them on each bubbling `input` / + * `change` event (`scrapeHeaderRecord` in `@object-ui/plugin-form`). The + * picker's only element in the form is its trigger, which carries the field's + * `name`: it read as the empty string, so a New Invoice in the home currency + * read as "no currency chosen" and a picked product's price was withheld from + * the line. These pin the two halves of the read: the trigger's `value` is the + * code, and a pick bubbles a `change` from the trigger once the new code is on + * it. + */ + +import { describe, it, expect } from 'vitest'; +import { render, screen, fireEvent, waitFor } from '@testing-library/react'; +import * as React from 'react'; +import { CurrencyCodePicker } from '../custom/currency-code-picker'; + +const labels = { placeholder: 'Pick a currency', search: 'Search', noResults: 'None', available: 'Available', all: 'All' }; + +function Host({ initial, onRead }: { initial?: string; onRead: (value: string) => void }) { + const [value, setValue] = React.useState(initial); + const ref = React.useRef(null); + React.useEffect(() => { + const host = ref.current!; + // The form host's read: the named element's value, on a bubbling change. + const read = () => onRead((host.querySelector('[name="currency_code"]') as HTMLButtonElement).value); + host.addEventListener('change', read); + return () => host.removeEventListener('change', read); + }, [onRead]); + return ( +
+ +
+ ); +} + +describe('CurrencyCodePicker read by a DOM-reading form host (objectstack#36321)', () => { + it('the named trigger carries the selected code as its value', () => { + render( {}} />); + expect((screen.getByRole('combobox') as HTMLButtonElement).value).toBe('USD'); + }); + + it('with no code the trigger value is empty, never a code of its own', () => { + render( {}} />); + expect((screen.getByRole('combobox') as HTMLButtonElement).value).toBe(''); + }); + + it('a pick bubbles one change from the trigger, read after the new code is on it', async () => { + const reads: string[] = []; + render( reads.push(v)} />); + // Opening on the seeded code announces nothing: only a changed code does. + expect(reads).toEqual([]); + + fireEvent.click(screen.getByRole('combobox')); + fireEvent.click(await screen.findByRole('option', { name: /^EUR/ })); + + await waitFor(() => expect(reads).toEqual(['EUR'])); + expect((screen.getByRole('combobox') as HTMLButtonElement).value).toBe('EUR'); + }); +}); diff --git a/ui/packages/components/src/custom/currency-code-picker.tsx b/ui/packages/components/src/custom/currency-code-picker.tsx index e2a57946d3d..a5fe02c1142 100644 --- a/ui/packages/components/src/custom/currency-code-picker.tsx +++ b/ui/packages/components/src/custom/currency-code-picker.tsx @@ -144,6 +144,22 @@ export function CurrencyCodePicker({ const [open, setOpen] = React.useState(false) const current = typeof value === "string" && value !== "" ? value : undefined const groups = currencyCodeGroups({ home, rated, used, current }) + + // The trigger is the picker's one element in the form (its list is portaled + // out), and a form host that reads its header off the DOM finds the field by + // the trigger's `name`: the master-detail form's line grid reads the + // header's currency that way (objectstack#36321). So the trigger carries the + // code as its `value`, and a changed code bubbles a `change` event from it, + // as a native select does when its value changes (Radix Select's hidden + // select does the same). Without them the host read the button's empty + // value, and a header in the home currency read as "no currency chosen". + const triggerRef = React.useRef(null) + const announced = React.useRef(current) + React.useEffect(() => { + if (announced.current === current) return + announced.current = current + triggerRef.current?.dispatchEvent(new Event("change", { bubbles: true })) + }, [current]) const item = (code: string) => (