diff --git a/.changeset/36226-details-divider-double-click-reset.md b/.changeset/36226-details-divider-double-click-reset.md new file mode 100644 index 00000000000..c15f8ed8d9f --- /dev/null +++ b/.changeset/36226-details-divider-double-click-reset.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-detail': patch +--- + +feat(console): a double-click on the record page's details divider resets the left column to its default width + +Clause-②: no — no public type or accept set; one interaction on an existing control +Metadata-protocol: none + +On a wide full record page the details are pinned to a left column, with a divider between them and the tabs that can be dragged or moved with the arrow keys, and the width is kept per reader and per object. A double-click on that divider now puts the column back to its default of 400 px and keeps that width, so the next record of the same object opens at the default too. A drag the double-click interrupts ends with it. The limits, the keyboard moves and the comment panel are unchanged. diff --git a/ui/packages/plugin-detail/README.md b/ui/packages/plugin-detail/README.md index 5925ee99bd7..ed8c6b9f656 100644 --- a/ui/packages/plugin-detail/README.md +++ b/ui/packages/plugin-detail/README.md @@ -845,37 +845,45 @@ page that keeps the default tab strip) is laid out by the width of the view it occupies — the full page, the split pane, the overlay drawer, the maximized pane, a phone — by one rule, never by the viewport: -| Container width | Layout | +| Where, and how wide | Layout | |---|---| -| 1120 px and up | Details · the right column (380 px). A details section takes up to three field columns; the 动态 panel shows five entries | -| 760 – 1119 px | Details · the right column (320 px). A details section takes up to two field columns; the 动态 panel shows three entries | -| below 760 px | One column: the details sections, then the right column's panels in their order | - -The right column holds the panels, each the same shape (a title and a count; -the header row opens the panel's whole face, the host's `?related=`): first -**动态** (Activity) — one stream of the discussion, the activity and, with -`enable.trackHistory`, the field changes, shown as a one-line composer, the -newest entries and 「查看全部 N 条 →」, which opens the stream in full with its -All / Activity / Discussion chips, a Changes chip while the record shows its -field history (the host's `RecordFieldHistoryContext`; it holds the audit's -field changes with their before and after values, and every activity event, -`created` and `updated` included, sits under Activity; one action that wrote -both an activity row and an audit entry is one row, its before and after values -on it), and paging -(`?related=timeline`) — then each related list in the reader's arrangement, then Approvals and -Attachments. The reader's ⊟ (`rightColumn`) takes the right column out of the -two-column tiers; there is no tabbed tier. - -A tab row closes the record header in every tier (`RecordTabRow`): 「概览」 -(Overview), then 动态, then one tab per related panel in the reader's -arrangement, each with its count. A tab is its panel's whole face: choosing it -draws the full list (every column, paging, sort, inline edit) or the full -stream below the row, with the header unchanged, and the URL carries it -(`?related=.`, `?related=timeline`); 「概览」 or Esc returns. The -row shows as many tabs as its own width fits, measured on every resize, and -folds the rest into 「+N ▾」, which lists them with their counts and ends with -the hidden panels' tabs. 「概览」, at least one more tab and the active tab are -always on the row. +| A full page whose content is at least 744 px wide (`RECORD_PAGE_PIN_MIN_WIDTH`: a 320 px left column, a 24 px gap, 400 px of tabs), with at least one other tab, and no field group placing a related table among the fields | The details pinned to a left column, 400 px by default, one field a row; beside it the tab row without the details, open on its first tab. Each side scrolls on its own | +| Anywhere else: a narrower page, a drawer, a pane, a phone, or a page that places a related table among its fields | The tab row with the details as its first tab (「详情」, Details), the open tab drawn the full width. The details take one field a row, except on a full page whose details are its only tab: up to three field columns there | + +No width draws a right column of summary panels any more. Each tab's count +carries what a panel said, and the reader's ⊟ (`rightColumn`) and `rail` are +ignored. `tier` (`recordPageTierFor`) is still taken and stamped on the page as +`data-record-page-tier`, but the layout above is decided by the page +content's own measured width. + +On a pinned page the left column narrows on its own to leave the tabs 400 px, +never below 320 px; under that the page is no longer pinned and the details +become its first tab again. The divider between the column and the tabs is a +separator: drag it, or move it with ← → (Home / End to either end); a +double-click puts the column back to the default. The width is the host's to +keep — `detailsWidth` and `onDetailsWidthChange`, per reader and per object in +the console — and a double-click keeps the default there too. + +A tab row closes the record header (`RecordTabRow`): 「详情」 (Details) where +the details are not pinned, then one tab per related list in the reader's +arrangement, then Attachments, Approvals, and 动态 (Activity) last, each with +its count. A tab is its panel's whole face: choosing it draws the full list +(every column, paging, sort, inline edit) or the full stream below the row, +with the header unchanged, and the URL carries it +(`?related=.`, `?related=timeline`); 「详情」 or Esc returns +where the details are a tab. The row shows as many tabs as its own width +fits, measured on every resize, and folds the rest into 「+N ▾」, which lists +them with their counts and ends with the hidden lists' tabs. The details tab +(where there is one), at least one more tab and the active tab are always on +the row. + +The 动态 tab is one stream of the discussion, the activity and, with +`enable.trackHistory`, the field changes, with All / Activity / Discussion +chips and a Changes chip while the record shows its field history (the host's +`RecordFieldHistoryContext`; it holds the audit's field changes with their +before and after values, and every activity event, `created` and `updated` +included, sits under Activity; one action that wrote both an activity row and +an audit entry is one row, its before and after values on it), and paging. The related panels load counts first and rows on demand (`RelatedCardStack`). Every panel's count is asked in one request set, and each panel is a diff --git a/ui/packages/plugin-detail/src/RecordPageColumns.tsx b/ui/packages/plugin-detail/src/RecordPageColumns.tsx index 11cf792db84..a35b4250759 100644 --- a/ui/packages/plugin-detail/src/RecordPageColumns.tsx +++ b/ui/packages/plugin-detail/src/RecordPageColumns.tsx @@ -12,6 +12,7 @@ import type { FieldContainerLike } from '@object-ui/core'; import { SchemaRenderer, toRenderableSchema, useRecordContext, useRecordPagePreferences } from '@object-ui/react'; import { RECORD_PAGE_DETAILS_MIN_WIDTH, + RECORD_PAGE_DETAILS_WIDTH, RECORD_PAGE_PINNED_GAP, RECORD_PAGE_TABS_MIN_WIDTH, RECORD_PAGE_TIMELINE_PANEL, @@ -363,7 +364,9 @@ const DETAILS_WIDTH_KEY_STEP = 16; * 拖宽,拖过的宽度按人记住」), sitting in the gap between the columns: a * vertical separator, dragged with the pointer or moved with ← → (Home / End * to either end). `onPreview` follows the drag; `onCommit` keeps the width - * once the drag ends. + * once the drag ends. A double-click keeps {@link RECORD_PAGE_DETAILS_WIDTH}, + * the width the page has when nothing is kept (objectstack#36226), and ends + * any drag it interrupts. */ const DetailsWidthHandle: React.FC<{ width: number; @@ -408,6 +411,11 @@ const DetailsWidthHandle: React.FC<{ drag.current = null; onPreview(null); }} + onDoubleClick={() => { + drag.current = null; + onPreview(null); + onCommit(RECORD_PAGE_DETAILS_WIDTH); + }} onKeyDown={(event) => { const next = event.key === 'ArrowLeft' ? width - DETAILS_WIDTH_KEY_STEP diff --git a/ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx b/ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx index 52bde4065cd..535aaa1644b 100644 --- a/ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RecordPageColumns.test.tsx @@ -270,6 +270,51 @@ describe('RecordPageColumns — the details pinned left on a wide full page (obj expect(onDetailsWidthChange).toHaveBeenCalledWith(460); }); + it('a double-click on the handle keeps the default 400 again, ends a drag, and the default holds on the next open (objectstack#36226)', () => { + harness.width = 1184; + // The host's per-reader store, read again by every mount (the console's + // workspace preference; 400 when nothing is kept). + const store: { width?: number } = {}; + const Host = () => { + const [width, setWidth] = React.useState(store.width ?? 400); + return ( + { store.width = next; setWidth(next); }} + /> + ); + }; + const drawHost = () => render( + + + , + ); + const first = drawHost(); + const handle = () => screen.getByRole('separator'); + fireEvent.pointerDown(handle(), { button: 0, clientX: 400, pointerId: 1 }); + fireEvent.pointerMove(handle(), { clientX: 520, pointerId: 1 }); + fireEvent.pointerUp(handle(), { clientX: 520, pointerId: 1 }); + expect(handle().getAttribute('aria-valuenow')).toBe('520'); + expect(store.width).toBe(520); + // The double-click's second press is still down when it lands: no drag + // outlives it, so the moves after it neither preview nor keep a width. + fireEvent.pointerDown(handle(), { button: 0, clientX: 520, pointerId: 1 }); + fireEvent.doubleClick(handle()); + expect(handle().getAttribute('aria-valuenow')).toBe('400'); + expect(grid(first.container).style.gridTemplateColumns).toBe('400px 24px minmax(0,1fr)'); + fireEvent.pointerMove(handle(), { clientX: 600, pointerId: 1 }); + fireEvent.pointerUp(handle(), { clientX: 600, pointerId: 1 }); + expect(handle().getAttribute('aria-valuenow')).toBe('400'); + expect(store.width).toBe(400); + first.unmount(); + const second = drawHost(); + expect(handle().getAttribute('aria-valuenow')).toBe('400'); + expect(grid(second.container).style.gridTemplateColumns).toBe('400px 24px minmax(0,1fr)'); + }); + it('a drawer or pane (no `fullPage`) never pins: the details stay its first tab', () => { harness.width = 1600; const { container } = drawPage(columns, { fullPage: false });