Skip to content

Commit b59bf99

Browse files
committed
feat(grid): a lookup chip in a list cell opens its record in the side drawer; lookup cells draw an edit button (#36015)
On the console's list page a single click on a lookup chip opens the record it names in the list's side drawer (`?recordId=&recordObject=`), the list and its selection kept; a click beside the chip only selects. A lookup cell draws a pencil on hover and while selected, through the same edit gate as a double-click. Person chips (lookups to sys_user) keep #36033's behaviour. Also corrects #36033's pending changeset and the plugin-grid docs, which said every lookup chip only selects. Claude-Session: https://claude.ai/code/session_01L6bhgWkLah49N6UoD4CS3S Co-authored-by: Claude <noreply@anthropic.com>
1 parent dc10b3b commit b59bf99

19 files changed

Lines changed: 601 additions & 25 deletions

‎.changeset/36015-list-cell-click-only-selects.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Metadata-protocol: none
1111

1212
On a grid with the select-first cell model (the console's list page), a plain click on a link a cell draws used to follow it: an email opened the mail program, a phone number the dialler, a URL a new tab, a lookup or user chip that record's page, and an image thumbnail its lightbox. The cell was not selected, so a reader who meant to select or edit the cell left the list instead. The email and phone cells also drew a copy button beside the value, easy to hit while selecting.
1313

14-
A plain click on any of these now selects the cell and opens nothing. To open one: Ctrl/Cmd-click it (as before), press the open button the selected cell shows on hover (only on the selected cell, never on the row hover), or press Ctrl/Cmd+Enter on the selected cell. A cell of several chips opens the first one that way. A double-click on the link edits the cell, as on any other cell. The name link is the one exception and opens the record on a single click, as before. The copy buttons are not drawn inside such a grid; Ctrl/Cmd+C copies the selected cell.
14+
A plain click on any of these now selects the cell and opens nothing. (A lookup chip on a list whose host opens records in place, the console's list page, opens that record in the side drawer instead.) To open one: Ctrl/Cmd-click it (as before), press the open button the selected cell shows on hover (only on the selected cell, never on the row hover), or press Ctrl/Cmd+Enter on the selected cell. A cell of several chips opens the first one that way. A double-click on the link edits the cell, as on any other cell. The name link is the one exception and opens the record on a single click, as before. The copy buttons are not drawn inside such a grid; Ctrl/Cmd+C copies the selected cell.
1515

1616
Outside the select-first model nothing changes: the record page, related lists, phone cards, kanban cards and every grid whose host does not turn on `cellSelection` keep their links and copy buttons.
1717

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/components': patch
3+
'@object-ui/fields': patch
4+
'@object-ui/plugin-grid': patch
5+
'@object-ui/plugin-list': patch
6+
'@object-ui/app-shell': patch
7+
---
8+
9+
feat(grid): on the list page a lookup chip opens its record in the side drawer, and a lookup cell has an edit button
10+
11+
Clause-②: yes (widening)
12+
Metadata-protocol: none
13+
14+
On the console's list page, a single click on a lookup chip (a record of another object, such as a contact's account) now opens that record in the side drawer over the list. The list stays where it was: closing the drawer leaves its scroll position and the selected cell as they were. The drawer's address carries the record and its object (`?recordId=…&recordObject=…`), so a reload keeps it open and Back closes it, as with the name cell's "Open in side panel" icon. A click beside the chips only selects the cell. A cell of several chips opens the chip that was clicked; Ctrl/Cmd+Enter on the selected cell opens the first one in the drawer; Ctrl/Cmd-click still opens the record's page in a new tab.
15+
16+
A lookup cell now draws an edit (pencil) button while the pointer is over it and while it is selected. It opens the cell's editor, as a double-click or Enter does, and it is not drawn when the cell cannot be edited (no permission, a read-only field, a locked record). It takes the place of the open button a selected cell shows.
17+
18+
A chip naming a person (an owner, a creator: a lookup to `sys_user`) keeps the behaviour it had: a single click only selects the cell, and it opens from the open button or Ctrl/Cmd+Enter. Email, phone and URL cells and the name column are unchanged. On a phone every record still opens as its page.
19+
20+
For hosts: `ListView` and `ObjectGrid` take a new runtime prop, `openReferencedRecord(objectName, recordId)`, that opens such a record in the host's place; `GridCellSelection` gains an optional `referenceCells` member (`isReferenceColumn`, `openRecord`), exported with its type `GridReferenceCells` from `@object-ui/components`. A host that passes neither keeps the previous behaviour, where a chip only selects its cell. `ReferencedRecordLink`'s anchor now carries `data-record-object` and `data-record-id`.

‎content/docs/frontend/plugins/plugin-grid.mdx‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -398,13 +398,21 @@ object and the view does not declare `userActions.editInline: false`, and
398398

399399
- **A click selects** a cell (a ring around it); it neither edits nor opens the
400400
record. Only the name link keeps its own click (it opens the record). Every
401-
other link a cell draws (an email, a phone number, a URL, a file, a lookup or
402-
user chip, an image thumbnail) is selected by a click too (objectstack#36015);
403-
to open it, Ctrl/Cmd-click it, press the **Open** button the selected cell
404-
shows on hover, or press Ctrl/Cmd+Enter. A cell of several chips opens the
405-
first one that way. The email and phone cells draw no copy button here:
406-
Ctrl/Cmd+C copies the selected cell. On a touch screen a tap opens the
407-
record.
401+
other link a cell draws (an email, a phone number, a URL, a file, a user
402+
chip, an image thumbnail, and a lookup chip unless the host opens it in
403+
place, below) is selected by a click too (objectstack#36015); to open it,
404+
Ctrl/Cmd-click it, press the **Open** button the selected cell shows on
405+
hover, or press Ctrl/Cmd+Enter. A cell of several chips opens the first one
406+
that way. The email and phone cells draw no copy button here: Ctrl/Cmd+C
407+
copies the selected cell. On a touch screen a tap opens the record.
408+
- **A lookup chip opens its record in place** when the host passes
409+
`openReferencedRecord` (the console's list page opens it in the side drawer,
410+
over the list): a single click on the chip opens that record, a click beside
411+
it selects the cell, and Ctrl/Cmd+Enter opens the first chip the same way. A
412+
lookup cell draws an **Edit** (pencil) button on hover and while selected,
413+
which opens its editor; it is not drawn when the cell cannot be edited, and
414+
it takes the place of the **Open** button. A chip naming a person (a lookup
415+
to `sys_user`) keeps the click-selects behaviour above.
408416
- **A cut-off value shows in full** when its cell is selected: a long text, a
409417
multi-line text or a list of tags that the column truncates opens on a
410418
layer over the cell, wrapped, scrolling inside past a few lines. Escape, an

‎ui/packages/app-shell/src/urlParams.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ import { NAV_RUN_ACTION_PARAM } from '@object-ui/layout';
8585
*/
8686
export const RECORD_DRAWER_PARAM = 'recordId';
8787

88+
/**
89+
* The object of the record the drawer's root shows, when it is not the
90+
* listed object's (objectstack#36015): a lookup chip in the list opens the
91+
* record it names in the list's drawer. Absent ⇒ the listed object. Read
92+
* only beside {@link RECORD_DRAWER_PARAM}.
93+
*/
94+
export const RECORD_DRAWER_OBJECT_PARAM = 'recordObject';
95+
8896
/** Global record-form overlay: `new` | `<recordId>` (framework#2604). */
8997
export const RECORD_FORM_PARAM = 'form';
9098

@@ -156,6 +164,7 @@ export { NAV_RUN_ACTION_PARAM };
156164
*/
157165
export const RESERVED_URL_PARAMS: readonly string[] = [
158166
RECORD_DRAWER_PARAM,
167+
RECORD_DRAWER_OBJECT_PARAM,
159168
RECORD_FORM_PARAM,
160169
RECORD_FORM_OBJECT_PARAM,
161170
RECORD_FORM_LINK_PARAM,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
10431043
// objectstack#27058 — on a phone the record is always a page: a row tap
10441044
// navigates to it, and no pane is mounted beside or over the list.
10451045
const phone = usePhoneViewport();
1046-
const { listRecordActions, navOverlay, handleDrawerClose, handleRowClick, handleOpenAsPage, handleOpenRowInPanel, drawerRoot, drawerRestore, handleListRowsChange, handleListTotalChange, handleRootStep, listLabel } = useObjectViewRecordNavigation({
1046+
const { listRecordActions, navOverlay, handleDrawerClose, handleRowClick, handleOpenAsPage, handleOpenRowInPanel, handleOpenReferencedRecord, drawerRoot, drawerRestore, handleListRowsChange, handleListTotalChange, handleRootStep, listLabel } = useObjectViewRecordNavigation({
10471047
activeView,
10481048
objectDef,
10491049
objects,
@@ -1069,6 +1069,9 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
10691069
: null),
10701070
[navOverlay.mode, phone, openInPanelLabel, handleOpenRowInPanel],
10711071
);
1072+
// objectstack#36015 — a lookup chip in the grid opens its record in the
1073+
// same side drawer, where this list has one.
1074+
const openReferencedRecord = navOverlay.mode === 'drawer' && !phone ? handleOpenReferencedRecord : undefined;
10721075

10731076
// objectstack#25992 slice 8: the `filter[...]` URL equality filters and the `uf_*`
10741077
// user-filter selections moved to `./objectViewListUrlState.ts`.
@@ -1184,6 +1187,7 @@ function ObjectViewInner({ dataSource, objects, onEdit, externalRefreshKey }: Co
11841187
handleListRowsChange,
11851188
handleListTotalChange,
11861189
openInPanel,
1190+
openReferencedRecord,
11871191
// objectstack#33317 — the resolved mode: `none` for an authored
11881192
// `none` and for a list-only object (`servesRecordRead`).
11891193
rowOpensRecord: navOverlay.mode !== 'none',

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export function useObjectViewListRenderer({
101101
handleListRowsChange,
102102
handleListTotalChange,
103103
openInPanel,
104+
openReferencedRecord,
104105
rowOpensRecord,
105106
phoneTitle,
106107
viewBarTrailing,
@@ -145,6 +146,8 @@ export function useObjectViewListRenderer({
145146
handleListTotalChange: ReturnType<typeof useObjectViewRecordNavigation>['handleListTotalChange'];
146147
/** objectstack#35854 — the name cell's 「在侧边打开」 (`./objectViewOpenAsPage.tsx`), or `null` for none. */
147148
openInPanel: { label: string; open: (recordId: string | number) => void } | null;
149+
/** objectstack#36015 — a lookup chip's record in the side drawer, or `undefined` where the list has none. */
150+
openReferencedRecord: ((objectName: string, recordId: string) => void) | undefined;
148151
/** objectstack#33317 — whether a row click opens the record: `false` for the `none` mode. */
149152
rowOpensRecord: boolean;
150153
/**
@@ -1182,6 +1185,9 @@ export function useObjectViewListRenderer({
11821185
: null;
11831186
}
11841187
: undefined}
1188+
// objectstack#36015 — a lookup chip in the grid opens the record it
1189+
// names in the same side drawer.
1190+
openReferencedRecord={openReferencedRecord}
11851191
// objectstack#33317 — a row that opens nothing (the view
11861192
// authored `navigation.mode: 'none'`, or a list-only object)
11871193
// draws no record link and no Open in its context menu.
@@ -1202,7 +1208,7 @@ export function useObjectViewListRenderer({
12021208
dataSource={ds}
12031209
/>
12041210
);
1205-
}, [hasViewBarTrailing, trailStore, rowEndStore, activeView, activeViewDeclaresColumns, activeViewIsSaved, objectDef, objectName, refreshKey, createRecord, urlFilters, initialUfSelections, handleUserFilterSelectionsChange, writeListUrlState, listPage, user?.id, pageOffersCreate, listAddRecordOpensCreate, listIdentityKey, listPrefs.ready, listPrefs.preference, listPrefs.patchView, listDraft.draft, listDraft.patch, managedUsers, managedUserMarker, openInPanel, rowOpensRecord, handleListRowsChange, handleListTotalChange, hasPhoneTitle, leadStore, wideViewport, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, offersRename, offersSave, offersReset, offersSummaryPick, summaryPickKey, previewDrafts, previewDataSource, unpublishedObjects]);
1211+
}, [hasViewBarTrailing, trailStore, rowEndStore, activeView, activeViewDeclaresColumns, activeViewIsSaved, objectDef, objectName, refreshKey, createRecord, urlFilters, initialUfSelections, handleUserFilterSelectionsChange, writeListUrlState, listPage, user?.id, pageOffersCreate, listAddRecordOpensCreate, listIdentityKey, listPrefs.ready, listPrefs.preference, listPrefs.patchView, listDraft.draft, listDraft.patch, managedUsers, managedUserMarker, openInPanel, openReferencedRecord, rowOpensRecord, handleListRowsChange, handleListTotalChange, hasPhoneTitle, leadStore, wideViewport, handleListPersonalizationChange, workspaceTimeZone, viewPanelFilters, offersRename, offersSave, offersReset, offersSummaryPick, summaryPickKey, previewDrafts, previewDataSource, unpublishedObjects]);
12061212

12071213
return { renderListView };
12081214
}

‎ui/packages/app-shell/src/views/objectViewRecordNavigation.listRows-27524.test.tsx‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,62 @@ describe('a page the list opens carries the list\'s rows (objectstack#27524, Tar
8282
expect(lastState(navigate)).toEqual({ from: { pathname: '/apps/crm/crm_lead?view=all', label: 'All leads' } });
8383
});
8484
});
85+
86+
describe('a lookup chip opens the record it names in the list\'s drawer (objectstack#36015)', () => {
87+
const OBJECTS = [{ name: 'crm_lead', label: 'Lead' }, { name: 'crm_account', label: 'Account' }];
88+
89+
function mountDrawer(search: string) {
90+
const navigate = vi.fn();
91+
const setSearchParams = vi.fn();
92+
const { result } = renderHook(() =>
93+
useObjectViewRecordNavigation({
94+
activeView: { id: 'all', name: 'all', label: 'All leads' } as never,
95+
objectDef: { name: 'crm_lead', label: 'Lead', fields: {} } as never,
96+
objects: OBJECTS as never,
97+
appName: 'crm',
98+
viewId: undefined,
99+
searchParams: new URLSearchParams(search),
100+
setSearchParams,
101+
location: { ...LIST, search: `?${search}` },
102+
navigate,
103+
routerRootHref: '/',
104+
servedViews: { views: [], objects: [] } as never,
105+
viewLabel: (_object: string, _view: string, fallback: string) => fallback,
106+
unlabelledViewText: 'Untitled view',
107+
language: 'en',
108+
phone: false,
109+
}),
110+
{ wrapper: ({ children }: { children: React.ReactNode }) => <MemoryRouter initialEntries={[`/apps/crm/crm_lead?${search}`]}>{children}</MemoryRouter> },
111+
);
112+
act(() => result.current.handleListRowsChange(ROWS));
113+
const lastParams = () => String(setSearchParams.mock.calls.at(-1)![0]);
114+
return { result, navigate, lastParams };
115+
}
116+
117+
it('another object\'s record: its id and its object in the URL, beside the list\'s own params', () => {
118+
const { result, lastParams } = mountDrawer('view=all');
119+
act(() => result.current.handleOpenReferencedRecord('crm_account', 'a7'));
120+
expect(lastParams()).toBe('view=all&recordId=a7&recordObject=crm_account');
121+
});
122+
123+
it('a record of the listed object opens as the name cell\'s icon opens it, with no object param', () => {
124+
const { result, lastParams } = mountDrawer('view=all&recordId=a7&recordObject=crm_account');
125+
act(() => result.current.handleOpenReferencedRecord('crm_lead', 'r-2'));
126+
expect(lastParams()).toBe('view=all&recordId=r-2');
127+
});
128+
129+
it('the drawer\'s root is that record, with no sibling set; an object the console does not know opens nothing', () => {
130+
expect(mountDrawer('recordId=a7&recordObject=crm_account').result.current.drawerRoot).toEqual({ objectName: 'crm_account', recordId: 'a7' });
131+
expect(mountDrawer('recordId=a7&recordObject=crm_unknown').result.current.drawerRoot).toBeNull();
132+
// The listed object's row keeps its sibling set.
133+
expect(mountDrawer('recordId=r-2').result.current.drawerRoot).toEqual({ objectName: 'crm_lead', recordId: 'r-2', siblings: ['r-1', 'r-2', 'r-3'] });
134+
});
135+
136+
it('closing the drawer drops both params; its full-page button opens that object\'s page', () => {
137+
const { result, navigate, lastParams } = mountDrawer('view=all&recordId=a7&recordObject=crm_account');
138+
act(() => result.current.handleDrawerClose());
139+
expect(lastParams()).toBe('view=all');
140+
act(() => result.current.handleOpenAsPage([{ objectName: 'crm_account', recordId: 'a7' }]));
141+
expect(navigate).toHaveBeenLastCalledWith('/apps/crm/crm_account/record/a7');
142+
});
143+
});

0 commit comments

Comments
 (0)