Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .changeset/36147-record-field-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
'@object-ui/plugin-detail': patch
'@object-ui/fields': patch
'@object-ui/i18n': patch
---

feat(console): the record page's field area is one list — one field a row in the side preview, on a phone and in the wide page's pinned left column

Clause-②: yes (widening)
Metadata-protocol: none

The synthesized record page's field area (objectstack#36147, ruling on the card 7066516044):

- **One column at any width.** The drawer (at any width), the split pane, the phone's 「详情」 tab, the wide page's pinned left column and a desktop full page that has other tabs but is not pinned (an opportunity's 详情 tab goes from three columns to one) draw the fields one a row: label left, value right, a hairline between rows. The phone's own grouped-inset face is gone there; it is the same list. A full page whose details are its only face (no other tab, none hidden) keeps laying a group out by width.
- **Group title row.** The title sits left and its chevron at the row's right end, pointing down while the group is folded and up while it is open; the whole row toggles.
- **Referenced records are chips.** A lookup value is drawn as a pill with the referenced object's colour tile (`ObjectSchema.color` / `icon`, objectstack#35985) and the record's whole name, wrapping rather than cut. A click on the chip opens the record; the rest of an editable lookup's row edits it. Everywhere else a reference keeps its link face.
- **Empty fields fold into one row.** Every empty field of every group is folded into the list's one last row (「显示 N 个空字段」), replacing the per-group toggle and the 「N 个空分组」 line on this page. The reader's choice is the per-object record-page preference `showEmptyFields` (objectstack#25883), so it holds for the next record of the object. An authored `hideEmpty` group stays hidden and is not counted.
- **「系统信息」 is the last group,** folded until opened: created by, created on, updated by, updated on (when the record was updated), the owner (when the body does not draw it) and the record ID, one fact a row. On this page it **replaces the one-line meta footer that objectui#12307 introduced**; outside the laid-out record page that line is unchanged.
- **A click edits; no pencil.** A single click on an editable value enters edit (a click on a link, a button or a text selection inside it is not taken); the hover pencil is no longer drawn, and stays in the DOM only as the keyboard's way in (visible on focus). A double click is no longer needed. **A read-only value takes no click any more**: the click-to-copy on read-only rows is removed on this page. For a mouse or a keyboard its copy icon, shown on hover or keyboard focus, stays; a touch screen shows none, and the value is selected by a long press.
- Authored record pages and every other DetailView keep their faces.

`@object-ui/fields` widens: it exports `ReferenceChipContext` (a boolean React context, default `false`) that switches `LookupCellRenderer`'s reference link to the chip face.

`@object-ui/i18n` widens: five new keys in every pack, `detail.systemInfo` (系统信息 / System information), `detail.createdTime`, `detail.updatedTime`, `detail.recordNumber` and `detail.clickToEdit`.
16 changes: 9 additions & 7 deletions ui/e2e/live/inline-edit-polish-2572.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ const REPO_ROOT = decodeURIComponent(new URL(import.meta.url).pathname)
.slice(0, -SELF_DEPTH_BELOW_REPO_ROOT)
.join('/');

const EDIT_HINT = 'Double-click to edit';
// 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';

function authToken(): string {
const state = JSON.parse(readFileSync(join(REPO_ROOT, 'e2e/live/.auth/state.json'), 'utf8'));
Expand Down Expand Up @@ -117,12 +119,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 (double-click a details-body field). ──
// ── Enter the shared inline-edit session (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}"]`).dblclick();
await spentGroup.locator(`[title="${EDIT_HINT}"]`).click();

const saveBtn = page.getByRole('button', { name: 'Save', exact: true });
await expect(saveBtn, 'save bar appears once the session is live').toBeVisible();
Expand All @@ -149,7 +151,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}"]`).dblclick();
await budgetGroup.locator(`[title="${EDIT_HINT}"]`).click();
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
Expand Down Expand Up @@ -220,7 +222,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}"]`).dblclick();
await budgetGroupOnPage().locator(`[title="${EDIT_HINT}"]`).click();
await expect(saveBtn, 'inline editing stays live during an unlocked approval').toBeVisible();
await page.keyboard.press('Escape');
await expect(saveBtn).toBeHidden();
Expand Down Expand Up @@ -261,7 +263,7 @@ test('record inline-edit polish (#2572) — showcase Project end-to-end', async
await expect(approvalTag, 'the header names the locking approval').toBeVisible();
await expect(approvalTag, 'the approval tag carries the lock').toHaveAttribute('data-record-approval-locked', '');

// …and a double-click on the (former) budget field must NOT open a session.
await budgetGroupOnPage().dblclick();
// …and a click on the (former) budget field must NOT open a session.
await budgetGroupOnPage().click();
await expect(saveBtn).toBeHidden();
});
9 changes: 6 additions & 3 deletions ui/e2e/live/read-only-member-record.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ const writesInquiry = writesRecordsOf(OBJECT);

// The record header's Edit CTA and the record body's inline-edit pencils carry
// no test id; their accessible names are the `detail.edit` and
// `detail.editInlineHint` strings, en or zh.
// `detail.editInlineHint` strings, en or zh, or `detail.clickToEdit` on the
// record page's field list (objectstack#36147), where the pencil is the
// keyboard's way in, `sr-only` until focused, so it is counted, not seen.
const editButton = (page: Page) => page.getByRole('button', { name: /^(Edit|编辑)$/ });
const inlineEditPencils = (page: Page) => page.getByRole('button', { name: /^(Double-click to edit|双击编辑)$/ });
const inlineEditPencils = (page: Page) =>
page.getByRole('button', { name: /^(Double-click to edit|双击编辑|Click to edit|点击编辑)$/ });

test.use({ viewport: { width: 1440, height: 900 } });

Expand Down Expand Up @@ -116,7 +119,7 @@ test('a member who may read but not write an inquiry gets a read-only form and n
await test.step('control, as the admin: the same form is editable and its save persists', async () => {
await page.goto(recordPath(id));
await expect(editButton(page)).toBeVisible({ timeout: 30_000 });
await expect(inlineEditPencils(page).first()).toBeVisible();
await expect.poll(() => inlineEditPencils(page).count(), { timeout: 30_000 }).toBeGreaterThan(0);

await page.goto(formPath(id));
const dialog = page.getByRole('dialog');
Expand Down
23 changes: 22 additions & 1 deletion ui/e2e/record-flow-phone-targets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ import { uiRoot } from '../scripts/ui-root.mjs';
* `min-h-[44px] sm:min-h-0` spellings) and shows the pencil on a coarse
* pointer. Above `sm` every control keeps its desktop size.
*
* On the synthesized record page's field list (objectstack#36147) a phone
* enters edit by tapping the value, and no pencil is drawn there: the pencil
* measured here is the one every other face of a section still draws
* (`PENCIL_CLASS`), and the field list's own button (`FIELD_LIST_PENCIL_CLASS`)
* is the keyboard's way in, `sr-only` until focused.
*
* ⚠️ A Playwright spec and not a vitest test for the reason
* `record-path-phone-row.spec.ts` gives: jsdom has no layout engine, so a
* size read there is 0 and an assertion on it is vacuous.
Expand Down Expand Up @@ -86,7 +92,8 @@ const CLS = {
cardRowName: g('related', /className="(min-h-11 [^"]*text-primary hover:underline[^"]*)"/, ['min-h-11', 'sm:min-h-0']),
cardMenu: g('cardMenu', /className="([^"]+)"\s*aria-label=\{t\('detail\.relatedCardMenu'/, ['h-11', 'w-11', 'sm:h-6']),
cardHandle: g('cardMenu', /'(inline-flex h-11 w-11 [^']*)'/, ['h-11', 'w-11', 'sm:h-6']),
pencil: g('section', /className="([^"]+)"\s*aria-label=\{t\('detail\.editInlineHint'\)\}/, ['min-h-[44px]', 'pointer-coarse:opacity-100', 'opacity-0']),
pencil: g('section', /const PENCIL_CLASS =\s*'([^']+)'/, ['min-h-[44px]', 'pointer-coarse:opacity-100', 'opacity-0']),
fieldListPencil: g('section', /const FIELD_LIST_PENCIL_CLASS = '([^']+)'/, ['sr-only', 'focus-visible:not-sr-only']),
stripPencil: g('strip', /className="([^"]+)"\s*aria-label=\{t\('detail\.editInlineHint'\)\}/, ['min-h-[44px]', 'pointer-coarse:opacity-100', 'opacity-0']),
saveCancel: g('saveBar', /disabled=\{inline\.saving\}\s*className="([^"]+)"/, ['h-11', 'sm:h-9']),
saveSave: g('saveBar', /disabled=\{inline\.saving \|\| locked\}\s*className="([^"]+)"/, ['h-11', 'sm:h-9']),
Expand Down Expand Up @@ -262,6 +269,20 @@ test.describe('the record flow at phone width (objectstack#29071)', () => {
});
}

test('on the field list a phone taps the value: its pencil takes no room and is no target until focused (objectstack#36147)', async ({ browser }) => {
const page = await open(browser, 375, 812, true);
await measure(page, `<div class="group flex items-start justify-between gap-2"><div class="text-sm flex-1 min-w-0 py-1">Acme Corp</div><button type="button" class="${CLS.buttonBase} ${CLS.fieldListPencil}" id="list-pencil"><svg width="12" height="12"></svg></button></div>`);
const before = await page.evaluate(() => document.getElementById('list-pencil')!.getBoundingClientRect());
expect(before.width).toBeLessThanOrEqual(1);
expect(before.height).toBeLessThanOrEqual(1);
// The keyboard's way in: focused, it is drawn at its own size.
// A keyboard focus (Tab), so `:focus-visible` holds.
await page.keyboard.press('Tab');
const focused = await page.evaluate(() => document.getElementById('list-pencil')!.getBoundingClientRect());
expect(focused.width).toBeGreaterThan(1);
await page.context().close();
});

test('above `sm`, with a mouse, the controls keep their desktop size and the pencil waits for hover', async ({ browser }) => {
const page = await open(browser, 1280, 800, false);
const r = await measure(page, fixture());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,9 @@ describe('RecordDetailView.recordEditState-35599', () => {

const headerButton = (label: string) =>
(Array.from(document.querySelectorAll('button')).find((b) => (b.textContent ?? '').trim() === label) as HTMLButtonElement | undefined) ?? null;
const pencils = (container: HTMLElement) => container.querySelectorAll('button[aria-label="Double-click to edit"]').length;
// The field list's pencil is named for a click (objectstack#36147), every other face's for a double-click.
const pencils = (container: HTMLElement) =>
container.querySelectorAll('button[aria-label="Double-click to edit"], button[aria-label="Click to edit"]').length;
const editor = (container: HTMLElement, id: string) => container.querySelector(`[data-body-table-editor="${id}"]`) as HTMLElement | null;
const cells = (scope: HTMLElement, label: string) => Array.from(scope.querySelectorAll(`input[aria-label="${label}"]`)) as HTMLInputElement[];
const summaryInput = (container: HTMLElement) =>
Expand Down Expand Up @@ -3058,9 +3060,13 @@ describe('RecordDetailView.recordEditState-35599', () => {
fireEvent.change(cells(tasks, 'Subject')[0], { target: { value: 'Visit' } });
}

/** The pencil of the Summary field (the inline-edit entry), on the details column. */
/**
* The pencil of the Summary field (the inline-edit entry), on the details
* column: the keyboard's way in on the field list, named for a click
* (objectstack#36147).
*/
const summaryPencil = (container: HTMLElement) =>
(Array.from(container.querySelectorAll('[data-record-column="details"] button[aria-label="Double-click to edit"]')) as HTMLElement[])
(Array.from(container.querySelectorAll('[data-record-column="details"] button[aria-label="Click to edit"]')) as HTMLElement[])
.find((b) => (b.closest('.group')?.textContent ?? '').includes('Summary')) ?? null;
const saveBar = () => document.querySelector('[role="region"][aria-label="Edit fields"]') as HTMLElement | null;
const detailInputValues = (container: HTMLElement) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@
* body draws the owner (the meta line does not), and an object whose body
* draws no `owner_id` (the field is `hidden`) keeps the owner on the meta
* line.
*
* On the laid-out page the meta line is the details column's last group,
* 「系统信息」 (objectstack#36147), folded until opened: the owner and the
* record ID it keeps are that group's rows, read here with the group opened.
*/

import * as React from 'react';
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, cleanup, waitFor } from '@testing-library/react';
import { render, cleanup, waitFor, fireEvent, within } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { MetadataCtx } from '@object-ui/react';
import { RelatedCountStore } from '@object-ui/components';
Expand Down Expand Up @@ -172,7 +176,17 @@ async function metaLineLoaded(): Promise<HTMLElement> {
);
}

const ownerEntry = (metaLine: HTMLElement) => metaLine.querySelector('[data-record-meta-owner]');
/** Open the 「系统信息」 group the meta line is on the laid-out page (objectstack#36147). */
function openSystemInfo(metaLine: HTMLElement) {
const toggle = within(metaLine).getByRole('button', { name: 'System information' });
if (toggle.getAttribute('aria-expanded') !== 'true') fireEvent.click(toggle);
}
/** The value of the system group's row labelled `label`, or `null`. */
const systemRow = (metaLine: HTMLElement, label: string) => {
const el = Array.from(metaLine.querySelectorAll('[data-detail-field-label]')).find((l) => l.textContent === label);
return (el?.closest('[data-detail-field-row]') as HTMLElement | null) ?? null;
};
const ownerEntry = (metaLine: HTMLElement) => systemRow(metaLine, 'Owner');
/** How many times the owner's name is painted on the whole page. */
const ownerCount = () => document.body.textContent!.split('Ada Admin').length - 1;

Expand Down Expand Up @@ -214,11 +228,12 @@ describe('the owner at every width, once (objectstack#28909)', () => {
mountPage();
const metaLine = await metaLineLoaded();
expect(document.querySelector('[data-highlights-face]')).toBeNull();
openSystemInfo(metaLine);
await waitFor(() => expect(ownerCount()).toBe(1));
expect(ownerEntry(metaLine)).toBeNull();
expect(metaLine.textContent).not.toContain('Ada Admin');
// The rest of the meta line is still drawn.
expect(metaLine.querySelector('[data-record-meta-id]')!.textContent).toBe('r-1');
expect(systemRow(metaLine, 'Record ID')!.textContent).toContain('r-1');
});

it.each([
Expand All @@ -229,11 +244,16 @@ describe('the owner at every width, once (objectstack#28909)', () => {
mountPage(OBJECTS_OWNER_HIDDEN);
const metaLine = await metaLineLoaded();
expect(document.querySelector('[data-highlights-face]')).toBeNull();
const owner = ownerEntry(metaLine);
openSystemInfo(metaLine);
const owner = await waitFor(() => {
const row = ownerEntry(metaLine);
expect(row?.textContent).toContain('Ada Admin');
return row;
});
expect(owner).toBeTruthy();
expect(owner!.textContent).toContain('Ada Admin');
expect(ownerCount()).toBe(1);
// The rest of the meta line is still drawn.
expect(metaLine.querySelector('[data-record-meta-id]')!.textContent).toBe('r-1');
expect(systemRow(metaLine, 'Record ID')!.textContent).toContain('r-1');
});
});
Loading
Loading