From 048beda66cec86c36d393350c0205ed7f0d27156 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 02:44:49 +0000 Subject: [PATCH 1/4] wip(plugin-detail): the enlarged related tab draws object-grid on desktop Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jV95ABcxitqSGp6kmv --- ui/packages/plugin-detail/src/RelatedList.tsx | 153 +++++++++++++++--- 1 file changed, 131 insertions(+), 22 deletions(-) diff --git a/ui/packages/plugin-detail/src/RelatedList.tsx b/ui/packages/plugin-detail/src/RelatedList.tsx index fb538c0beab..301f3993b4c 100644 --- a/ui/packages/plugin-detail/src/RelatedList.tsx +++ b/ui/packages/plugin-detail/src/RelatedList.tsx @@ -31,7 +31,7 @@ import { useIsMobile, RelatedCountStore, } from '@object-ui/components'; -import { SchemaRenderer, useCapabilityGate, useCondition, toPredicateInput, useSettledSchema, useFilterScope, useResolvedFilter, usePredicateScope, classifyLoadError, declaredUserMessage, extractWriteErrorMessage, type LoadErrorKind, type RelatedRowActionDef } from '@object-ui/react'; +import { SchemaRenderer, ActionCtxReact, useAction, useCapabilityGate, useCondition, toPredicateInput, useSettledSchema, useFilterScope, useResolvedFilter, usePredicateScope, classifyLoadError, declaredUserMessage, extractWriteErrorMessage, type LoadErrorKind, type RelatedRowActionDef } from '@object-ui/react'; import { Plus, ExternalLink, @@ -2728,28 +2728,45 @@ export const RelatedList: React.FC = ({ const viewSchema = React.useMemo(() => { if (schema) return schema; + // objectstack#28865 (#27524 item 9) — the ENLARGED tab is the child + // object's list face, on a desktop as on a phone (objectstack#28484): the + // list page's grid, `object-grid`, over the rows this list already read. + // The grid draws the row height and density, the name link, the row + // actions and (under 768 px) the phone list's card rows. Resolved through + // the registry: `plugin-grid` depends on this package, so it cannot be + // imported here. + // + // This list stays the source of truth for everything the rows came from. + // Its window, page and sort reach the grid on the grid's HOST channel + // (`enlargedGridHost`, the React props `plugin-list`'s `ListView` hands + // it), never as node keys; the filter box, the chips, 新建 and 导出 stay + // in this list's toolbar; its own pager stays the one pager, so the + // grid's is off. + if (enlargedFace && (type === 'grid' || type === 'table')) { + return { + type: 'object-grid', + objectName: api, + data: { provider: 'value', items: paginatedData }, + columns: effectiveColumns + .map((c: any) => c.accessorKey || columnIdentity(c)) + .filter(Boolean), + showSearch: false, + showPagination: false, + // The host's row actions (`list_item`, and `record_related` inside a + // parent record), already localized — the non-author host key the + // console's object page hands the same grid. A dispatch from them is + // routed back to `onRowAction` (`enlargedGridActions`). + ...(hasCustomRowActions && onRowAction ? { rowActionDefs: rowActions } : {}), + onRowClick: handleRowClick, + }; + } + // Mobile: render grid/table data as a card gallery — single-column, // tap-friendly, visually consistent with the standalone gallery view. // Reuses the registered `object-gallery` schema so we don't ship a // duplicate renderer. Falls back to the data-table on desktop and // when explicit `type='list'` is requested (legacy path). if (isMobile && (type === 'grid' || type === 'table')) { - // objectstack#28484 — the ENLARGED tab's phone cards are the phone - // list's card rows (`object-grid`'s card face: the name, one subtitle - // line, one status chip) at the body's full width, over the rows this - // list already read. Resolved through the registry: `plugin-grid` - // depends on this package, so it cannot be imported here. - if (enlargedFace) { - return { - type: 'object-grid', - objectName: api, - data: { provider: 'value', items: paginatedData }, - columns: effectiveColumns - .map((c: any) => c.accessorKey || columnIdentity(c)) - .filter(Boolean), - onRowClick: handleRowClick, - }; - } const titleField = effectiveColumns[0]?.accessorKey || columnIdentity(effectiveColumns[0]); const visibleFields = effectiveColumns .slice(1, 4) @@ -2827,6 +2844,82 @@ export const RelatedList: React.FC = ({ } }, [type, paginatedData, tableColumns, effectiveColumns, schema, effectivePageSize, hasRowActions, hasCustomRowActions, rowActions, onRowAction, onRowEdit, onRowDelete, handleDeleteRow, handleRowClick, isMobile, compact, enlargedFace, api, objectSchema, activeSort, handleTableSort]); + const enlargedGrid = enlargedFace && !schema && (type === 'grid' || type === 'table'); + + /** + * objectstack#28865 — the enlarged face's grid, driven by this list on the + * grid's host channel: the React props `ObjectGrid` reads when a host owns + * the rows (`ObjectGridExternalPaginationProps`), the channel `plugin-list`'s + * `ListView` uses. Spread on `SchemaRenderer` as props, never node keys. + * + * - `manualPagination` with this list's page and count: `data` IS the page + * this list holds, so the grid neither slices nor re-pages it. The grid's + * pager is off (`showPagination: false` on the node); this list's pager + * answers a window whose total the server did not send (`hasMore`), which + * a pager over a row count cannot. + * - `sort` / `onSortChange` are this list's sort (objectui#3106), in BOTH + * of its modes: windowed it is the server's `$orderby`; while the filter + * box has text the list sorts its in-memory rows itself. Under a host + * sort the grid offers no header sort on a relational column (the stored + * value is an id, not the name the cell shows), in either mode. + * - `objectFields`: the definition this list already read, so no column + * paints withheld while the grid reads its own (objectui#10657). + * - `onEdit` / `onDelete`: this list's row Edit and its confirm-then-delete. + */ + const enlargedGridHost = React.useMemo(() => { + if (!enlargedGrid) return undefined; + const heldBefore = currentPage * (effectivePageSize || 0); + const rowCount = windowed + ? total ?? heldBefore + relatedData.length + (hasMore ? 1 : 0) + : sortedData.length; + return { + manualPagination: true, + rowCount, + page: currentPage + 1, + pageSize: Math.max(1, effectivePageSize || paginatedData.length), + onPageChange: (page: number) => setCurrentPage(Math.max(0, page - 1)), + sort: activeSort, + onSortChange: handleTableSort, + ...(objectSchema?.fields ? { objectFields: objectSchema.fields } : {}), + ...(onRowEdit ? { onEdit: onRowEdit } : {}), + ...(onRowDelete ? { onDelete: handleDeleteRow } : {}), + }; + }, [enlargedGrid, windowed, total, currentPage, effectivePageSize, relatedData.length, hasMore, sortedData.length, paginatedData.length, activeSort, handleTableSort, objectSchema, onRowEdit, onRowDelete, handleDeleteRow]); + + /** + * objectstack#28865 — where a row action the enlarged grid dispatches goes. + * + * The grid runs a row action def through the surrounding action runner with + * the row under `params._rowRecord` and no object of its own: on the record + * page that runner's object is the PARENT's, and nothing tells this list to + * read its rows again afterwards. The host that handed this list its row + * actions also handed it `onRowAction`, which dispatches against the child + * object and its row and signals the child object changed — the path the + * row menu of the table this face drew before took. So a dispatch carrying + * one of THIS list's action defs and a row goes there; every other dispatch + * (a bulk action, anything the grid runs without a row) reaches the + * surrounding runner unchanged. + */ + const outerActions = useAction(); + const outerActionsRef = React.useRef(outerActions); + outerActionsRef.current = outerActions; + const enlargedGridActions = React.useMemo(() => { + if (!enlargedGrid || !hasCustomRowActions || !onRowAction) return null; + const execute = async (action: any): Promise => { + const row = action?.params?._rowRecord; + const def = row && typeof action?.name === 'string' + ? rowActions!.find((candidate) => candidate.name === action.name) + : undefined; + if (!def) return outerActionsRef.current.execute(action); + await onRowAction(def, row); + return { success: true }; + }; + return { ...outerActions, execute }; + // `outerActions` is read through the ref for dispatch; the spread only + // carries the runner's state fields, which the grid does not read. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [enlargedGrid, hasCustomRowActions, rowActions, onRowAction]); + const headerClassName = isCollapsible ? 'cursor-pointer select-none' : undefined; const handleHeaderClick = isCollapsible ? () => setCollapsed((c) => !c) : undefined; @@ -3165,6 +3258,12 @@ export const RelatedList: React.FC = ({ // tab names the list, and its count is the 全部 chip's. if (enlargedFace) { const shownCount = filterActive ? filteredData.length : recordCount; + // objectstack#28865 — one count: while the 全部 chip is on and nothing + // narrows the rows, the chip already says how many there are, so the + // line under the toolbar does not say it again. A chip that narrows (我的, + // 逾期) or a filter text keeps the line's count, which is then a + // different number from the chip's. + const countOnChip = chips.length > 1 && enlargedChip === 'all' && !filterActive && allCount !== null && allCount === shownCount; const chipLabel: Record = { all: t('detail.relatedChipAll', { defaultValue: 'All' }), mine: t('detail.relatedChipMine', { defaultValue: 'Mine' }), @@ -3308,12 +3407,22 @@ export const RelatedList: React.FC = ({ ) : ( <> -
- {t('detail.relatedRows', { count: shownCount, defaultValue: '{{count}} rows' })} - {showPagination && ` · ${t('detail.pageOf', { current: currentPage + 1, total: totalPages })}`} -
+ {(!countOnChip || showPagination) && ( +
+ {[ + countOnChip ? null : t('detail.relatedRows', { count: shownCount, defaultValue: '{{count}} rows' }), + showPagination ? t('detail.pageOf', { current: currentPage + 1, total: totalPages }) : null, + ].filter(Boolean).join(' · ')} +
+ )}
- + {enlargedGridActions ? ( + + + + ) : ( + + )}
{showPagination && (
From edab633af0cd34812efdd052417da9dadfb37e38 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 02:46:41 +0000 Subject: [PATCH 2/4] test(plugin-detail): pin the enlarged related tab's desktop list grid, its host channel and one count Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jV95ABcxitqSGp6kmv --- .../28865-enlarged-related-list-grid.md | 14 + ...elatedList.enlargedListGrid-28865.test.tsx | 240 ++++++++++++++++++ ...atedList.enlargedPhoneCards-28484.test.tsx | 10 +- ...RelatedList.enlargedToolbar-27524.test.tsx | 25 +- 4 files changed, 282 insertions(+), 7 deletions(-) create mode 100644 .changeset/28865-enlarged-related-list-grid.md create mode 100644 ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedListGrid-28865.test.tsx diff --git a/.changeset/28865-enlarged-related-list-grid.md b/.changeset/28865-enlarged-related-list-grid.md new file mode 100644 index 00000000000..520dd79f3cb --- /dev/null +++ b/.changeset/28865-enlarged-related-list-grid.md @@ -0,0 +1,14 @@ +--- +'@object-ui/plugin-detail': patch +--- + +fix(plugin-detail): on a desktop the record page's enlarged related tab draws the child object's list grid, as the phone already does + +Clause-②: no +Metadata-protocol: none + +The enlarged related tab (the record page's active tab) drew a generic `data-table` on a desktop: rows about 65 px tall where the child object's list page draws 41 px, a name in plain text that did not open the record, and the count twice (on the 全部 chip and on the line under the toolbar). It now renders `object-grid` over the rows the related list already read, the branch the phone has taken since the phone card rows landed, so the tab is the child object's list face: the list page's row height and density, the name as a link that opens the record, and the grid's row actions. + +The related list stays the source of truth. Its window, page and sort reach the grid as host props (the ones the list view hands the same grid), so paging and sort are still the server's `$top` / `$skip` / `$orderby`, and its own pager stays the one pager. The filter box, the 全部 / 我的 / 逾期 chips, 新建 and 导出 are unchanged. The host's row actions (`list_item`, and `record_related` inside a parent record) ride to the grid's row menu and still dispatch through the host against the child object and its row, which refreshes the list. While the 全部 chip is on and nothing narrows the rows, the line under the toolbar no longer repeats the chip's count. + +One behaviour changes: while the filter box has text, the grid offers no header sort on a relational column (its stored value is an id), as on every list page; the data-table sorted that column by its label in that state. Compact panels in the right column and lists that are not enlarged are unchanged. diff --git a/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedListGrid-28865.test.tsx b/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedListGrid-28865.test.tsx new file mode 100644 index 00000000000..b59c6110b67 --- /dev/null +++ b/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedListGrid-28865.test.tsx @@ -0,0 +1,240 @@ +/** + * 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#28865 (#27524 item 9) — on a desktop the ENLARGED related tab is + * the child object's list face: `object-grid` over the rows this list read, + * the branch the phone takes since objectstack#28484, never the generic + * `data-table`. + * + * The list stays the source of truth: its window, page and sort reach the grid + * on the grid's host channel (React props on `SchemaRenderer`, the ones + * `plugin-list`'s `ListView` hands the same grid), its own pager stays the one + * pager, and a row action the grid dispatches goes back to the host's + * `onRowAction`. The count shows once. + */ + +import { describe, it, expect, vi, afterEach, beforeAll } from 'vitest'; +import { cleanup, render, screen, waitFor, fireEvent, act } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import * as React from 'react'; +import { FilterScopeProvider } from '@object-ui/react'; +import { RelatedList } from '../RelatedList'; +import { RelatedListEnlargedContext } from '../relatedListCompact'; + +/** + * Capture what `RelatedList` hands to `SchemaRenderer` — the node and the host + * props beside it — and the action runner the grid would read there. + */ +const h = vi.hoisted(() => ({ + schema: null as any, + props: null as any, + execute: null as null | ((action: any) => Promise), +})); +vi.mock('@object-ui/react', async (importOriginal) => { + const actual = await importOriginal>(); + function CapturingRenderer({ schema, ...props }: any) { + const actions = actual.useAction(); + h.schema = schema; + h.props = props; + h.execute = actions.execute; + return null; + } + return { ...actual, SchemaRenderer: CapturingRenderer }; +}); + +beforeAll(() => { + Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 1440 }); +}); + +afterEach(() => { + cleanup(); + h.schema = null; + h.props = null; + h.execute = null; +}); + +const FIELDS = { + name: { type: 'text', label: 'Name' }, + amount: { type: 'currency', label: 'Amount' }, + account: { type: 'lookup', reference: 'account', label: 'Account' }, + owner_id: { type: 'lookup', reference: 'sys_user', label: 'Owner' }, +}; +const TOTAL = 30; +const ALL_ROWS = Array.from({ length: TOTAL }, (_, i) => ({ + id: `o${i + 1}`, + name: `Deal ${i + 1}`, + amount: (i + 1) * 1000, + account: 'A-1', + owner_id: i === 0 ? 'u-1' : 'u-2', +})); + +function dataSourceFor() { + return { + find: vi.fn(async (_object: string, params: any) => { + const mine = JSON.stringify(params?.$filter ?? null).includes('owner_id'); + const rows = mine ? ALL_ROWS.filter((row) => row.owner_id === 'u-1') : ALL_ROWS; + const skip = params?.$skip ?? 0; + const top = params?.$top ?? rows.length; + return { data: rows.slice(skip, skip + top), total: rows.length }; + }), + getObjectSchema: vi.fn(async () => ({ name: 'opportunity', fields: FIELDS })), + }; +} + +const ROW_ACTIONS = [{ name: 'close_won', label: 'Close won', locations: ['record_related'] }]; + +function renderList({ + enlarged = true, + onRowAction, + onRowEdit, + onRowDelete, +}: { + enlarged?: boolean; + onRowAction?: (...args: any[]) => any; + onRowEdit?: (row: any) => void; + onRowDelete?: (row: any) => void; +} = {}) { + const dataSource = dataSourceFor(); + const utils = render( + + + + + , + ); + return { ...utils, dataSource }; +} + +const lastFind = (find: ReturnType) => find.mock.calls[find.mock.calls.length - 1][1]; + +describe('the enlarged related tab on a desktop is the child object list face (objectstack#28865)', () => { + it('hands object-grid the page it read, with its columns, and turns off the grid’s own pager and search', async () => { + renderList(); + await waitFor(() => expect(h.schema?.data?.items).toHaveLength(25)); + expect(h.schema.type).toBe('object-grid'); + expect(h.schema.objectName).toBe('opportunity'); + expect(h.schema.data.provider).toBe('value'); + expect(h.schema.data.items[0].id).toBe('o1'); + expect(h.schema.columns).toEqual(['name', 'amount', 'owner_id']); + expect(h.schema.showPagination).toBe(false); + expect(h.schema.showSearch).toBe(false); + }); + + it('drives the grid on its host channel: this list’s window, page and sort, never node keys', async () => { + renderList(); + await waitFor(() => expect(h.props?.rowCount).toBe(TOTAL)); + expect(h.props).toMatchObject({ manualPagination: true, page: 1, pageSize: 25, sort: [] }); + expect(h.props.objectFields).toEqual(FIELDS); + for (const key of ['manualPagination', 'rowCount', 'page', 'onPageChange', 'onSortChange', 'objectFields']) { + expect(h.schema, `${key} rides the host channel, not the node`).not.toHaveProperty(key); + } + }); + + it('a header sort from the grid is this list’s sort: one server $orderby, from the first page', async () => { + const { dataSource } = renderList(); + await waitFor(() => expect(h.props?.rowCount).toBe(TOTAL)); + act(() => h.props.onSortChange([{ field: 'amount', order: 'desc' }])); + await waitFor(() => expect(lastFind(dataSource.find).$orderby).toEqual([{ field: 'amount', order: 'desc' }])); + expect(lastFind(dataSource.find).$skip).toBe(0); + await waitFor(() => expect(h.props.sort).toEqual([{ field: 'amount', order: 'desc' }])); + }); + + it('a page from the grid is this list’s page: the next window is read from the server', async () => { + const { dataSource } = renderList(); + await waitFor(() => expect(h.props?.rowCount).toBe(TOTAL)); + act(() => h.props.onPageChange(2)); + await waitFor(() => expect(lastFind(dataSource.find).$skip).toBe(25)); + await waitFor(() => expect(h.schema.data.items.map((row: any) => row.id)).toEqual(['o26', 'o27', 'o28', 'o29', 'o30'])); + expect(h.props.page).toBe(2); + // This list's own pager is the one pager. + expect(screen.getByText('Previous')).toBeInTheDocument(); + }); + + it('DEVIATION, pinned: while the filter box has text the grid still gets this list’s sort on the host channel', async () => { + // The list sorts its in-memory rows itself in this state (it read them + // all). Handed as a HOST sort, the grid's manual-sort rule applies: it + // offers no header sort on a relational column (`owner_id` here), whose + // stored value is an id. The data-table this face drew before sorted that + // column by its label in this one state. + renderList(); + await waitFor(() => expect(h.props?.rowCount).toBe(TOTAL)); + fireEvent.change(screen.getByRole('searchbox'), { target: { value: 'Deal 1' } }); + await waitFor(() => expect(h.props.rowCount).toBe(11)); + expect(h.props.manualPagination).toBe(true); + expect(h.props.onSortChange).toEqual(expect.any(Function)); + expect(h.schema.data.items.every((row: any) => row.name.startsWith('Deal 1'))).toBe(true); + }); + + it('the count shows once: on the 全部 chip, not again on the line under the toolbar', async () => { + renderList(); + await waitFor(() => expect(document.querySelector('[data-related-chip="all"]')?.textContent).toBe(`All${TOTAL}`)); + // The line keeps only the page; it no longer repeats the 30. + expect(document.querySelector('[data-related-enlarged-status]')?.textContent).toBe('Page 1 of 2'); + }); + + it('a chip that narrows keeps its own count on the line, a different number from 全部’s', async () => { + renderList(); + await waitFor(() => expect(document.querySelector('[data-related-chip="all"]')?.textContent).toBe(`All${TOTAL}`)); + fireEvent.click(document.querySelector('[data-related-chip="mine"]')!); + await waitFor(() => expect(document.querySelector('[data-related-enlarged-status]')?.textContent).toMatch(/^1 row/)); + }); + + it('row actions: the host’s defs ride to the grid, and a dispatch from the grid reaches onRowAction with the row', async () => { + const onRowAction = vi.fn(async () => undefined); + renderList({ onRowAction }); + await waitFor(() => expect(h.schema?.data?.items).toHaveLength(25)); + expect(h.schema.rowActionDefs).toEqual(ROW_ACTIONS); + const row = h.schema.data.items[2]; + // The grid's own dispatch shape (`objectGridActionsColumn` `onActionDef`). + const result = await h.execute!({ name: 'close_won', label: 'Close won', params: { _rowRecord: row } }); + expect(onRowAction).toHaveBeenCalledTimes(1); + expect(onRowAction).toHaveBeenCalledWith(ROW_ACTIONS[0], row); + expect(result).toEqual({ success: true }); + }); + + it('CONTROL: a dispatch that is not one of this list’s row actions reaches the surrounding runner', async () => { + const onRowAction = vi.fn(async () => undefined); + renderList({ onRowAction }); + await waitFor(() => expect(h.schema?.data?.items).toHaveLength(25)); + await h.execute!({ type: 'some_bulk_action', params: { records: [] } }).catch(() => undefined); + await h.execute!({ name: 'not_ours', params: { _rowRecord: h.schema.data.items[0] } }).catch(() => undefined); + expect(onRowAction).not.toHaveBeenCalled(); + }); + + it('row Edit and Delete are this list’s: Edit hands the row on, Delete asks first', async () => { + const onRowEdit = vi.fn(); + const onRowDelete = vi.fn(); + renderList({ onRowEdit, onRowDelete }); + await waitFor(() => expect(h.schema?.data?.items).toHaveLength(25)); + expect(h.props.onEdit).toBe(onRowEdit); + act(() => h.props.onDelete(h.schema.data.items[0])); + expect(await screen.findByRole('alertdialog')).toBeInTheDocument(); + expect(onRowDelete).not.toHaveBeenCalled(); + }); + + it('CONTROL: a related list that is not enlarged keeps the data-table on a desktop, with no host props', async () => { + renderList({ enlarged: false }); + await waitFor(() => expect(h.schema?.type).toBe('data-table')); + expect(h.props).toEqual({}); + }); +}); diff --git a/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedPhoneCards-28484.test.tsx b/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedPhoneCards-28484.test.tsx index c521f73be66..6bd8913f2e8 100644 --- a/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedPhoneCards-28484.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedPhoneCards-28484.test.tsx @@ -13,8 +13,9 @@ * inset `object-gallery`. The rows are the ones this list read, inline; a tap * still reaches the host's `onRowClick` with the row. * - * Controls: a related list that is NOT enlarged keeps the gallery on a phone, - * and the enlarged tab at a desktop width keeps the table. + * Control: a related list that is NOT enlarged keeps the gallery on a phone. + * At a desktop width the enlarged tab takes the same `object-grid` branch + * since objectstack#28865 (`RelatedList.enlargedListGrid-28865.test.tsx`). */ import { describe, it, expect, vi, afterEach } from 'vitest'; @@ -112,9 +113,10 @@ describe('the enlarged related tab on a phone draws the phone list card rows (ob await waitFor(() => expect(h.schema?.type).toBe('object-gallery')); }); - it('CONTROL: the enlarged tab at a desktop width keeps the table', async () => { + it('the enlarged tab at a desktop width takes the same object-grid branch (objectstack#28865)', async () => { setWidth(1280); renderList({ enlarged: true }); - await waitFor(() => expect(h.schema?.type).toBe('data-table')); + await waitFor(() => expect(h.schema?.data?.items).toHaveLength(2)); + expect(h.schema.type).toBe('object-grid'); }); }); diff --git a/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx b/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx index 52d4a10e12a..7fc88f4b798 100644 --- a/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx @@ -22,11 +22,29 @@ import { render, screen, waitFor, fireEvent, within } from '@testing-library/rea import '@testing-library/jest-dom'; import React from 'react'; import { FilterScopeProvider } from '@object-ui/react'; +import { ComponentRegistry } from '@object-ui/core'; import { RelatedList } from '../RelatedList'; import { RelatedListEnlargedContext } from '../relatedListCompact'; +/** + * The enlarged face draws `object-grid` (objectstack#28865), which + * `plugin-grid` registers and this package cannot import (`plugin-grid` + * depends on it). A stand-in draws the rows it is handed, as a table. + */ +function ObjectGridStandIn({ schema }: { schema: any }) { + const rows: any[] = schema?.data?.items ?? []; + const columns: string[] = schema?.columns ?? []; + return ( + + {columns.map((c) => )} + {rows.map((row) => {columns.map((c) => )})} +
{c}
{String(row[c] ?? '')}
+ ); +} + beforeAll(() => { Object.defineProperty(window, 'innerWidth', { configurable: true, value: 1280 }); + ComponentRegistry.register('object-grid', ObjectGridStandIn as never); }); const TASK_FIELDS = { @@ -94,12 +112,13 @@ describe('the enlarged related list draws the board toolbar (objectstack#27524)' fireEvent.click(within(bar).getByTestId('related-list-new')); expect(onNew).toHaveBeenCalledTimes(1); expect(bar.querySelector('[data-related-enlarged-export]')).not.toBeNull(); - // The count and page line sits between the toolbar and the table. - expect(document.querySelector('[data-related-enlarged-status]')?.textContent).toBe('2 rows'); + // The count shows once (objectstack#28865): the 全部 chip says 2, so the + // line under the toolbar, which holds no page either, is not drawn. + expect(document.querySelector('[data-related-enlarged-status]')).toBeNull(); // No card: no header title, no count badge, no View all. expect(screen.queryByLabelText('2 records')).toBeNull(); expect(document.querySelector('.rounded-xl, [class*="card"]')).toBeNull(); - expect(document.querySelector('thead')).not.toBeNull(); + expect(document.querySelector('[data-object-grid-stand-in] thead')).not.toBeNull(); }); it('我的 and 逾期 narrow the list\'s own read, beside the parent', async () => { From 287dd21eb3f5e3989b5259402ddf387afe34f319 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 02:53:08 +0000 Subject: [PATCH 3/4] refactor(plugin-detail): route the enlarged grid's row actions without a ref written in render Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jV95ABcxitqSGp6kmv --- ui/packages/plugin-detail/src/RelatedList.tsx | 47 ++++++++++++++----- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/ui/packages/plugin-detail/src/RelatedList.tsx b/ui/packages/plugin-detail/src/RelatedList.tsx index 301f3993b4c..33a3f4b0891 100644 --- a/ui/packages/plugin-detail/src/RelatedList.tsx +++ b/ui/packages/plugin-detail/src/RelatedList.tsx @@ -31,7 +31,7 @@ import { useIsMobile, RelatedCountStore, } from '@object-ui/components'; -import { SchemaRenderer, ActionCtxReact, useAction, useCapabilityGate, useCondition, toPredicateInput, useSettledSchema, useFilterScope, useResolvedFilter, usePredicateScope, classifyLoadError, declaredUserMessage, extractWriteErrorMessage, type LoadErrorKind, type RelatedRowActionDef } from '@object-ui/react'; +import { SchemaRenderer, ActionCtxReact, useCapabilityGate, useCondition, toPredicateInput, useSettledSchema, useFilterScope, useResolvedFilter, usePredicateScope, classifyLoadError, declaredUserMessage, extractWriteErrorMessage, type LoadErrorKind, type RelatedRowActionDef } from '@object-ui/react'; import { Plus, ExternalLink, @@ -80,6 +80,9 @@ import { resolveAffordance, isDeadlineSettled, isActionSwitchedOff, + ActionRunner, + type ActionDef, + type ActionResult, type FilterNode, } from '@object-ui/core'; import { useSafeFieldLabel } from '@object-ui/react'; @@ -408,6 +411,26 @@ type FieldReadPolicy = ReturnType; * so the field the card reads and the field the request carries cannot drift * apart. The value is `ObjectGallery`'s own default, so the cover is unchanged. */ +/** + * The action context a component reading `useAction()` gets when no + * `ActionProvider` is above it: a local runner, in the shape `useAction()`'s + * own fallback returns. The enlarged grid's routed context + * (`enlargedGridActions`) hands every dispatch that is not this list's row + * action to it, so the grid behaves under the routed context exactly as it + * would have without one. + */ +function localActionContext(runner: ActionRunner): React.ContextType & object { + return { + execute: (action) => runner.execute(action), + executeChain: (actions, mode) => runner.executeChain(actions, mode), + loading: false, + error: null, + result: null, + runner, + updateContext: (ctx) => runner.updateContext(ctx), + }; +} + const MOBILE_GALLERY_COVER_FIELD = 'image'; /** @@ -2898,27 +2921,25 @@ export const RelatedList: React.FC = ({ * row menu of the table this face drew before took. So a dispatch carrying * one of THIS list's action defs and a row goes there; every other dispatch * (a bulk action, anything the grid runs without a row) reaches the - * surrounding runner unchanged. + * surrounding runner unchanged — or, with no `ActionProvider` above, the + * local runner the grid's own `useAction()` would have made. */ - const outerActions = useAction(); - const outerActionsRef = React.useRef(outerActions); - outerActionsRef.current = outerActions; + const outerActions = React.useContext(ActionCtxReact); const enlargedGridActions = React.useMemo(() => { if (!enlargedGrid || !hasCustomRowActions || !onRowAction) return null; - const execute = async (action: any): Promise => { - const row = action?.params?._rowRecord; + const surrounding = outerActions ?? localActionContext(new ActionRunner()); + const execute = async (action: ActionDef): Promise => { + const params = action?.params as Record | undefined; + const row = params?._rowRecord; const def = row && typeof action?.name === 'string' ? rowActions!.find((candidate) => candidate.name === action.name) : undefined; - if (!def) return outerActionsRef.current.execute(action); + if (!def) return surrounding.execute(action); await onRowAction(def, row); return { success: true }; }; - return { ...outerActions, execute }; - // `outerActions` is read through the ref for dispatch; the spread only - // carries the runner's state fields, which the grid does not read. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [enlargedGrid, hasCustomRowActions, rowActions, onRowAction]); + return { ...surrounding, execute }; + }, [enlargedGrid, hasCustomRowActions, rowActions, onRowAction, outerActions]); const headerClassName = isCollapsible ? 'cursor-pointer select-none' : undefined; const handleHeaderClick = isCollapsible ? () => setCollapsed((c) => !c) : undefined; From 8893cd2f6b1ffa70ea0bf035cc0714848d1d5561 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 02:57:09 +0000 Subject: [PATCH 4/4] test(app-shell): the enlarged tab's row menu is the list grid's Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01QsR2jV95ABcxitqSGp6kmv --- .../RecordDetailView.childWriteRefreshesParent-12244.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/packages/app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx index b578fd142e0..016ff5315cc 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.childWriteRefreshesParent-12244.test.tsx @@ -279,7 +279,9 @@ describe('RecordDetailView — a child write in a related list refreshes the par expect(headerBefore).toBeTruthy(); const row = screen.getByText('Seat licence').closest('tr')!; - await userEvent.click(within(row).getByRole('button', { name: 'Row actions' })); + // The enlarged tab draws the child object's list grid (objectstack#28865), + // so the row menu is the grid's. + await userEvent.click(within(row).getByTestId('row-action-trigger')); await userEvent.click(await screen.findByTestId('row-action-builtin-delete')); const dialog = await screen.findByRole('alertdialog'); await userEvent.click(within(dialog).getByRole('button', { name: /delete/i }));