Skip to content

Commit e9da898

Browse files
fix(console): the data page's side drawer draws the open-as-full-page button (#36427)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbUq2j5tRRVo3TVY3wcS1Fdg)_ Fixes #36300 repo:objectstack#7 · zhuangjianguo · session_01QsR2jV3scu6UYPb42n5okQ Clause-②: no Metadata-protocol: none ## 维护者速读 - 控制台的裸数据页上,从右侧抽屉打开记录后,抽屉顶栏多出「整页打开」按钮;点它进记录整页,整页上点关闭回到原来带条件的数据页。 - 属于「记录详情页重做」专题,让数据页的抽屉跟对象列表的抽屉一样,两处不再不一致。 - 用数据页看记录的人会碰到;出错时最多是按钮不出现或进整页后回不到原页,改动可以整体撤回。 - 无。 ## What changes The bare data page (`ObjectDataPage`, the app's object `data` route) mounts its record drawer with `NavigationOverlay`, and now hands it `onExpand`: the drawer's top bar draws the same ⤢ 「Open as full page」 button (`record-pane-open-page`) the object list's drawer draws, because it is that same control of the shared overlay, not a copy. - **⤢ opens the record's full page with the origin a name click carries.** The name click's navigation (the record URL plus the history-state `from` built by `listOriginOf`, and the phone's pushed-page marker) moved into one callback, `openRecordPage`, which both the name click and the drawer's ⤢ call. So the two entries cannot drift: the page's top bar counts the record among the data page's rows, ↑ ↓ step through them, and ✕ returns to the data page with its conditions. - **The drawer closes first**, as the object list's ⤢ does (`handleOpenAsPage` closes the drawer, then navigates): `listOriginOf` already strips `?recordId=` from the origin, so the ✕ lands on the data page with no drawer. - The button is drawn only while a served record is open (`openedRecordId`); a list-only object still opens no drawer at all. ## Tests Pinned beside the data page's open rule, as a new top-level `describe` in `ObjectDataPage.openRule-35875.test.tsx` (it is the data page's open-path harness: the real `ObjectDataPage`, `ListView` grid and `MePermissionsProvider`, and a record-route probe reading the origin through `useRecordPageReturn`): - the drawer opened from the hover icon draws a button named 「Open as full page」 (`record-pane-open-page`); a click opens `.../record/a2` with `from` equal to the data page's URL with its condition, its name, its rows and its matched count, position 2 of the matched count, and the drawer gone; - the full page's ✕ after ⤢ returns to the data page with `filter[status]=active`, no `recordId`, and no drawer. <details><summary>Local runs (head 07ac145)</summary> - vitest, `ObjectDataPage.openRule-35875.test.tsx`: `Test Files 1 passed (1)`, `Tests 8 passed (8)` (lock VERDICT command-exit 0). - vitest, every test file under `ui/` that names `ObjectDataPage` (38 files, incl. `ListView.test.tsx`, `ObjectView.harness.test.tsx`, the `ObjectView.listOnlyRecordPage-33219` and `ObjectView.rowOpensNothing-33317` control cases): `Test Files 38 passed (38)`, `Tests 808 passed (808)` (lock VERDICT command-exit 0). - `pnpm --filter @object-ui/app-shell type-check` (both tsc programs, the test program included): exit 0, 0 `error TS`. - Ablation, through `scripts/ablation-replace.mjs`, the `onExpand` line deleted from the data page's drawer (the control not passed): anchor 1 -> 0, blob `b7c74b61cd04` -> `b535a4ea7f93`; 2 red, both new cases, each `Unable to find an accessible element with the role "button" and name "Open as full page"`; the 6 existing cases green. Restored: blob == HEAD `b7c74b61cd04`, `git diff HEAD` empty. The subject is `src`, imported relatively, so no build leg. - `dispatch-gates --ran`: 38 derived, 38 run, 0 NOT-MEASURED, every one exit 0 (a derived zero). - `check:nul-bytes`: OK. `overlap-check`: `VERDICT clean`, origin/main merges cleanly. </details> ## Acceptance notes - Read first, by risk: `ui/packages/app-shell/src/views/ObjectDataPage.tsx` (`openRecordPage`, `openDrawerRecordAsPage`, the `NavigationOverlay` mount's `onExpand`). - Two-minute check: open any object's data page in the Console (`/apps/APP/OBJECT/data?filter[FIELD]=VALUE`), hover a row and click the small panel icon after the name: the drawer opens with a ⤢ in its top bar; click it: the record's full page opens; click ✕: back on the data page with the condition chip and no drawer. - The object list's drawer also offers 「Open as full page」 as the last item of the record header's ⋯ menu (`RecordPaneContext`, provided by `RecordStackDrawer`); the data page's drawer mounts `NavigationOverlay` directly and provides no pane context, so its ⋯ menu has no such item, before and after this change. The card asks for the ⤢ button only; noted, not filed. Read from code, not measured on a running page. - The claim's file surface named a new card-named test file; the pin is a top-level `describe` in the existing open-rule harness file instead, per the repository's rule that a new pin for a component with a harness goes into that file (ruling record 6583487846), so the harness is not copied. --- _Generated by [Claude Code](https://claude.ai/code/session_01QsR2jV3scu6UYPb42n5okQ)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8a741ab commit e9da898

3 files changed

Lines changed: 79 additions & 9 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(console): the bare data page's side drawer draws ⤢ 「Open as full page」
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
On the bare data page (`/apps/APP/OBJECT/data`), the side drawer a record opens in (from the name cell's 「Open in side panel」 icon, or a `?recordId=` link) now draws the same ⤢ 「Open as full page」 button in its top bar that the object list's drawer draws. It closes the drawer and opens the record's full page with the same origin a click on the record's name carries: the data page's URL with its conditions, its name, the rows it shows and the count it matched. The full page's ✕ returns to the data page with its conditions and no drawer.

‎ui/packages/app-shell/src/views/ObjectDataPage.openRule-35875.test.tsx‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,3 +305,45 @@ describe('objectstack#35875 — the bare data page opens a record by the list\'s
305305
expect(screen.queryByTestId('record-page')).toBeNull();
306306
});
307307
});
308+
309+
describe('objectstack#36300 — the data page\'s side drawer draws ⤢ 「Open as full page」', () => {
310+
/** The name cell's hover icon, then the drawer it opens. */
311+
async function openDrawer(text: string, id: string): Promise<HTMLElement> {
312+
fireEvent.click(within(rowOf(text)).getByTestId('record-open-in-panel'));
313+
await waitFor(() => expect(new URLSearchParams(search() ?? '').get('recordId')).toBe(id));
314+
return screen.findByRole('dialog', undefined, { timeout: 5000 });
315+
}
316+
317+
it('the drawer\'s ⤢ opens the full page with the origin a name click carries, and the drawer closes', async () => {
318+
await mountDataPage();
319+
const drawer = await openDrawer('Globex', 'a2');
320+
const expand = within(drawer).getByRole('button', { name: 'Open as full page' });
321+
expect(expand.getAttribute('data-testid')).toBe('record-pane-open-page');
322+
fireEvent.click(expand);
323+
await screen.findByTestId('record-page', undefined, { timeout: 5000 });
324+
expect(pathname()).toBe(`/apps/sales/${OBJECT_NAME}/record/a2`);
325+
// The origin is the data page with its conditions, without the drawer's `?recordId=`.
326+
expect(JSON.parse(screen.getByTestId('record-from').textContent ?? 'null')).toEqual({
327+
pathname: `${DATA_PATH}?${new URLSearchParams(DATA_SEARCH).toString()}`,
328+
label: 'Accounts',
329+
siblings: ['a1', 'a2'],
330+
total: MATCHED,
331+
});
332+
expect(screen.getByTestId('record-position').textContent).toBe(`2/${MATCHED}`);
333+
expect(screen.queryByRole('dialog')).toBeNull();
334+
});
335+
336+
it('the full page\'s ✕ after ⤢ returns to the data page with its conditions and no drawer', async () => {
337+
await mountDataPage();
338+
const drawer = await openDrawer('Acme', 'a1');
339+
fireEvent.click(within(drawer).getByRole('button', { name: 'Open as full page' }));
340+
fireEvent.click(await screen.findByTestId('record-close', undefined, { timeout: 5000 }));
341+
await screen.findByText('Globex', undefined, { timeout: 5000 });
342+
expect(pathname()).toBe(DATA_PATH);
343+
const params = new URLSearchParams(search() ?? '');
344+
expect(params.get('filter[status]')).toBe('active');
345+
expect(params.get('recordId')).toBeNull();
346+
await settle();
347+
expect(screen.queryByRole('dialog')).toBeNull();
348+
});
349+
});

‎ui/packages/app-shell/src/views/ObjectDataPage.tsx‎

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ export function ObjectDataPage({ dataSource, objects }: any) {
406406
// name, the rows it shows and the count it matched), so the page's ✕ comes
407407
// back here and its ↑ ↓ step through these rows. The name cell's hover icon
408408
// 「在侧边打开」 opens the side drawer over the list instead, URL-driven
409-
// (`?recordId=…` is shareable and refresh-safe). A click on any other cell
409+
// (`?recordId=…` is shareable and refresh-safe), and that drawer's ⤢ opens
410+
// the same full page with the same origin. A click on any other cell
410411
// selects it and opens nothing (the grid's select-first model). An object
411412
// the server does not read one record of (`servesRecordRead`, a list-only
412413
// object) has no record surface: its rows open nothing.
@@ -442,13 +443,10 @@ export function ObjectDataPage({ dataSource, objects }: any) {
442443
const handleListTotalChange = React.useCallback((total: number) => {
443444
listTotalRef.current = total;
444445
}, []);
445-
const handleRecordClick = React.useCallback(
446-
(record: any, event?: any) => {
447-
if (!recordServed) return;
448-
const id = record?.id ?? record?._id;
449-
if (id == null || id === '') return;
450-
const isMod = !!(event && (event.metaKey || event.ctrlKey || event.button === 1));
451-
if (isMod) { window.open(recordUrl(id), '_blank'); return; }
446+
// The record's full page, with this page as its origin: the one way to it,
447+
// from the name and from the side drawer's ⤢ alike (objectstack#36300).
448+
const openRecordPage = React.useCallback(
449+
(id: string | number) => {
452450
const { pathname, search } = locationRef.current;
453451
navigate(recordUrl(id), {
454452
state: {
@@ -467,7 +465,18 @@ export function ObjectDataPage({ dataSource, objects }: any) {
467465
},
468466
});
469467
},
470-
[recordServed, recordUrl, navigate, phone],
468+
[recordUrl, navigate, phone],
469+
);
470+
const handleRecordClick = React.useCallback(
471+
(record: any, event?: any) => {
472+
if (!recordServed) return;
473+
const id = record?.id ?? record?._id;
474+
if (id == null || id === '') return;
475+
const isMod = !!(event && (event.metaKey || event.ctrlKey || event.button === 1));
476+
if (isMod) { window.open(recordUrl(id), '_blank'); return; }
477+
openRecordPage(id);
478+
},
479+
[recordServed, recordUrl, openRecordPage],
471480
);
472481
// The name cell's 「在侧边打开」: the record in the side drawer over the list,
473482
// for a row with a record surface on a desktop. A phone opens every record
@@ -494,6 +503,14 @@ export function ObjectDataPage({ dataSource, objects }: any) {
494503
setSearchParams((prev) => { const n = new URLSearchParams(prev); n.delete(RECORD_DRAWER_PARAM); return n; });
495504
}, [setSearchParams]);
496505
const openedRecordId = recordServed ? drawerRecordId : null;
506+
// The drawer bar's ⤢ 「Open as full page」, as the object list's drawer
507+
// draws it (objectstack#36300): the drawer closes and the record's full page
508+
// opens with the same origin a name click carries, so its ✕ comes back here.
509+
const openDrawerRecordAsPage = React.useCallback(() => {
510+
if (!openedRecordId) return;
511+
closeRecordDrawer();
512+
openRecordPage(openedRecordId);
513+
}, [openedRecordId, closeRecordDrawer, openRecordPage]);
497514
React.useEffect(() => {
498515
if (openedRecordId && !navOverlay.isOpen) navOverlay.open({ id: openedRecordId });
499516
else if (!openedRecordId && navOverlay.isOpen) navOverlay.close();
@@ -928,6 +945,7 @@ export function ObjectDataPage({ dataSource, objects }: any) {
928945
<NavigationOverlay
929946
{...navOverlay}
930947
setIsOpen={(open: boolean) => { if (!open) closeRecordDrawer(); }}
948+
onExpand={openedRecordId ? openDrawerRecordAsPage : undefined}
931949
title={servedObjectLabel(objectDef, language, objectLabel)}
932950
>
933951
{(record: any) => (

0 commit comments

Comments
 (0)