Skip to content

Commit 80341f2

Browse files
fix(app-shell): on a phone, a list authored to open nothing opens nothing (#37946)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoAoNwrZVJoUEFfvMURpRPKJ)_ Fixes #33719 Clause-②: no Metadata-protocol: none ## 维护者速读 - 手机上打开一个设为「不打开记录」的列表时,点卡片不再进入记录页,卡片也不再显示为可点;分享来的带记录参数的链接同样不打开,和桌面一致。 - 落实你在该卡上裁定的 A:作者声明的「不打开」在手机上也算数,属于 Console 手机端体验收口。 - 只影响本来就声明了「不打开」的列表;出错表现为这类列表在手机上又能点开或其他列表点不开,可直接撤回本改动。 - 无 ## What changes Ruling A on #33719 (triage comment 6897459964, maintainer 「都同意」): on a phone, an authored `navigation.mode: 'none'` and `navigation.preventNavigation: true` hold, as on a desktop. - `detailNavigation` in `ui/packages/app-shell/src/views/objectViewRecordNavigation.ts` now reads the authored navigation once and returns `none` for `preventNavigation` or `mode === 'none'` **before** the phone rule (#27058), which still answers `page` for every list that does open. The tap handler and the card's tappable face both read the resolved mode (`rowOpensRecord`, #33548), so the one move carries both. - Scope item 2, the `?recordId=` deep link: on a desktop a `none` list's link draws no pane (`NavigationOverlay` shows a record only in `drawer` mode). The phone branch of the URL-sync effect navigated to the record page regardless of the mode; it now returns when the resolved mode is `none`, so a phone opens no page either. The URL is left as it is, as on a desktop. - Scope item 3: one docs sentence in `content/docs/ui/views.mdx` (How a list opens a record): on a phone the columns a card does not show are unreachable on such a list, so declare `none` / `preventNavigation` only where the rows need no detail view. - File header of `objectViewRecordNavigation.ts` updated to say the phone rule decides how a record opens, never whether (consistent with the #35854 header text already there). - Changeset: `@object-ui/app-shell` patch. ## Tests New pin `ui/packages/app-shell/src/views/ObjectView.phoneNavigationNone-33719.test.tsx`, driven at 375 px through the real `ObjectView`, `ListView`, grid and `MePermissionsProvider`: - for each of `mode: 'none'` and `preventNavigation: true`: the phone card draws no pointer / hover wash and a tap opens nothing (no `/record/`, no `window.open`); - for each spelling: a `?recordId=c1` link leaves the console on the list URL and draws no drawer; - CONTROL: a list with no authored navigation keeps its pointer, and both its tap and its `?recordId=` link open the record page. <details><summary>Readings (head 6b4f34b)</summary> - New pin + neighbours (`ObjectView.cardFacesOpenNothing-33548`, `ObjectView.phoneRecordPage-27058`, `objectViewRecordNavigation.phonePush-29074`, `objectViewRecordNavigation.listRows-27524`): Test Files 5 passed (5), Tests 44 passed (44); lock VERDICT command-exit 0. - Ablation, whole fix reverted to base (`git restore --source=73d5e347`): Tests 4 failed, 2 passed (6) — all four `none` / `preventNavigation` pins red, both CONTROLs green. - Ablation, only the deep-link guard removed: Tests 2 failed, 4 passed (6) — exactly the two `?recordId=` pins red. - `pnpm --filter @object-ui/app-shell run type-check` (both `tsc --noEmit` and `tsconfig.test.json`, which compiles the new test): exit 0. - `pnpm --dir ui check:new-line-citations`: 0 new citations. </details> ## Acceptance notes - AGENTS.md asks a new pin for a component with a shared harness file to go into that file. `ObjectView` has no shared harness file (only per-card files), and the dispatch named one new file for this card, so the pin carries its own copy of the 33548 file's mount harness (grid face only). - The `?recordId=` link on a `none` list keeps its `?recordId=` in the URL on both viewports; nothing reads it there. Not changed (desktop behaviour is the reference per the ruling). ## Verification Read first, by risk: 1. `ui/packages/app-shell/src/views/objectViewRecordNavigation.ts` — the `detailNavigation` reorder, and the `detailNavigation.mode === 'none'` guard in the phone branch of the URL-sync effect. 2. `ui/packages/app-shell/src/views/ObjectView.phoneNavigationNone-33719.test.tsx`. 3. `content/docs/ui/views.mdx`. Two-minute check: `pnpm --dir ui exec vitest run packages/app-shell/src/views/ObjectView.phoneNavigationNone-33719.test.tsx` — expect 6 passed. --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibx7DSQZnugnuX8CpCM)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d1139f9 commit 80341f2

4 files changed

Lines changed: 289 additions & 11 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): on a phone, a list authored to open nothing opens nothing
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The Console's object list now honours an authored `navigation.mode: 'none'` and `navigation.preventNavigation: true` on a phone as it does on a desktop. Before, the phone rule that opens every record as a page ran before the authored setting was read, so on a phone a tap on such a list's card opened the record page and the card was drawn as tappable. Now the card draws no pointer and no hover wash, a tap on it opens nothing, and a `?recordId=` link to one of its rows opens no record page, as it opens no drawer on a desktop. A list that opens its records still opens them as a page on a phone.
11+
12+
On a phone a list shows each row as a card with only some of its columns, so on a `none` list the columns a card does not show cannot be reached there: declare `none` or `preventNavigation` only where the rows need no detail view.

‎content/docs/ui/views.mdx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,9 @@ the page. A ⌘/Ctrl or middle click on the name opens the page in a new tab.
610610
one that declares nothing. `none` keeps its meaning, the rows open nothing; prefer
611611
`navigation: { preventNavigation: true }` for that. Omit the key. `modal`, `split` and `popover`
612612
were removed in @objectstack/spec 18.3.0 (ADR-0087 D2): a stored value is refused with its fix,
613-
and `os migrate meta --from 17` drops it.
613+
and `os migrate meta --from 17` drops it. `none` and `preventNavigation` hold on a phone too,
614+
where a list draws each row as a card showing only some of its columns, so the columns a card
615+
does not show are unreachable there: declare either only where the rows need no detail view.
614616
615617
The page a list opens remembers that list: its top bar counts the record among the list's
616618
rows (**N of M**, M being the records the list matched), steps to the previous and next of
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* objectstack#33719 (ruling A) — on a phone, an authored "no navigation" holds.
11+
*
12+
* The phone rule (objectstack#27058) decides HOW a record opens — as a page,
13+
* since a phone has no drawer — never WHETHER it opens. A list whose view
14+
* authors `navigation: { mode: 'none' }` or `navigation: { preventNavigation:
15+
* true }` therefore resolves to `none` on a phone as on a desktop: its phone
16+
* card draws no pointer and no hover wash (`rowOpensRecord`), a tap on it
17+
* opens nothing, and a `?recordId=` link to one of its rows opens no record
18+
* page (the desktop draws no pane for it).
19+
*
20+
* Driven at 375 px through the real `ObjectView`, `ListView`, grid and
21+
* `MePermissionsProvider`: one differential per spelling, the same object and
22+
* rows, only the view's `navigation` differs. CONTROL: a list with no authored
23+
* navigation keeps its pointer, and both its tap and its `?recordId=` link
24+
* open the record page.
25+
*
26+
* The record body is not what this file reads, so `RecordDetailView` is a
27+
* null sink.
28+
*/
29+
30+
import * as React from 'react';
31+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
32+
import { render, cleanup, screen, fireEvent, waitFor } from '@testing-library/react';
33+
import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
34+
import { createI18n, I18nProvider } from '@object-ui/i18n';
35+
import { MePermissionsProvider, type MePermissionsAuthenticatedResponse } from '@object-ui/permissions';
36+
import { SchemaRendererProvider } from '@object-ui/react';
37+
38+
vi.mock('@object-ui/auth', async (importOriginal) => ({
39+
...(await importOriginal<Record<string, unknown>>()),
40+
useAuth: () => ({ user: { id: 'u1', name: 'Ada' }, activeOrganization: null }),
41+
useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }),
42+
createAuthenticatedFetch: () => vi.fn(),
43+
}));
44+
45+
vi.mock('@object-ui/collaboration', async (importOriginal) => ({
46+
...(await importOriginal<Record<string, unknown>>()),
47+
useRealtimeSubscription: () => ({ lastMessage: null }),
48+
useConflictResolution: () => ({ hasConflicts: false, resolveAllConflicts: () => {} }),
49+
}));
50+
51+
vi.mock('sonner', () => ({
52+
toast: Object.assign(vi.fn(), {
53+
success: vi.fn(), error: vi.fn(), info: vi.fn(),
54+
warning: vi.fn(), loading: vi.fn(), dismiss: vi.fn(),
55+
}),
56+
}));
57+
58+
vi.mock('./MetadataInspector', () => ({
59+
MetadataPanel: () => null,
60+
useMetadataInspector: () => ({ showDebug: false, toggle: () => {} }),
61+
}));
62+
// The record body: not what this file reads.
63+
vi.mock('./RecordDetailView', () => ({ RecordDetailView: () => null }));
64+
65+
vi.mock('./metadata-admin/useMetadata', async (importOriginal) => ({
66+
...(await importOriginal<Record<string, unknown>>()),
67+
useMetadataClient: () => ({ save: vi.fn(async () => ({})), get: vi.fn(async () => null) }),
68+
}));
69+
70+
// `ObjectView` reaches a dynamic `import('@objectstack/lint')`: pay its load at
71+
// collection, never inside a case's clocked window (`check:test-source-alias`).
72+
import '@objectstack/lint';
73+
import { ObjectView } from './ObjectView';
74+
import { ExpressionProvider } from '../providers/ExpressionProvider';
75+
76+
const OBJECT_NAME = 'demo_credential';
77+
const VIEW_ID = 'all';
78+
const LIST_PATH = `/apps/setup/${OBJECT_NAME}/view/${VIEW_ID}`;
79+
const PHONE_WIDTH = 375;
80+
81+
const ROWS = [
82+
{ id: 'c1', name: 'Okta staging', connection: 'okta-staging' },
83+
{ id: 'c2', name: 'Azure prod', connection: 'azure-prod' },
84+
];
85+
86+
type Navigation = { mode?: 'none'; preventNavigation?: boolean };
87+
88+
/** The two authored spellings of "rows open nothing". */
89+
const NO_NAVIGATION: Array<[string, Navigation]> = [
90+
['`navigation.mode: none`', { mode: 'none' }],
91+
['`navigation.preventNavigation: true`', { preventNavigation: true }],
92+
];
93+
94+
/** The object and its one grid view, carrying `navigation` when given. */
95+
function objectsWith(navigation?: Navigation) {
96+
return [
97+
{
98+
name: OBJECT_NAME,
99+
label: 'Credential',
100+
pluralLabel: 'Credentials',
101+
nameField: 'name',
102+
fields: {
103+
id: { type: 'text', label: 'Id' },
104+
name: { type: 'text', label: 'Name' },
105+
connection: { type: 'text', label: 'Connection' },
106+
},
107+
listViews: {
108+
[VIEW_ID]: {
109+
name: VIEW_ID,
110+
label: 'All',
111+
type: 'grid',
112+
columns: ['name', 'connection'],
113+
...(navigation ? { navigation } : {}),
114+
},
115+
},
116+
},
117+
];
118+
}
119+
120+
/** The caller's `/me/permissions` answer: a served object it may read. */
121+
const ANSWER = {
122+
authenticated: true,
123+
userId: 'u1',
124+
tenantId: null,
125+
positions: [],
126+
hasAnyQueue: false,
127+
objectsUsingQueues: [],
128+
permissionSets: ['admin'],
129+
systemPermissions: [],
130+
objects: {
131+
[OBJECT_NAME]: { allowRead: true, allowCreate: true, allowEdit: true, allowDelete: true },
132+
},
133+
fields: {},
134+
} as MePermissionsAuthenticatedResponse;
135+
136+
let openSpy: ReturnType<typeof vi.fn>;
137+
const DESKTOP_WIDTH = window.innerWidth;
138+
139+
beforeEach(() => {
140+
vi.spyOn(HTMLElement.prototype, 'scrollIntoView').mockImplementation(() => {});
141+
vi.stubGlobal(
142+
'fetch',
143+
vi.fn(async () =>
144+
new Response(JSON.stringify({ data: [] }), {
145+
status: 200,
146+
headers: { 'content-type': 'application/json' },
147+
}),
148+
),
149+
);
150+
openSpy = vi.fn(() => null);
151+
vi.stubGlobal('open', openSpy);
152+
Object.defineProperty(window, 'innerWidth', { value: PHONE_WIDTH, configurable: true, writable: true });
153+
});
154+
155+
afterEach(() => {
156+
cleanup();
157+
vi.unstubAllGlobals();
158+
vi.restoreAllMocks();
159+
Object.defineProperty(window, 'innerWidth', { value: DESKTOP_WIDTH, configurable: true, writable: true });
160+
window.history.replaceState(null, '', '/');
161+
});
162+
163+
/** Where the console stands: its path and its query. */
164+
function LocationProbe() {
165+
const location = useLocation();
166+
return <div data-testid="location">{location.pathname + location.search}</div>;
167+
}
168+
169+
/** Mounts the list at phone width, at `LIST_PATH` plus `search`. */
170+
function mountList(navigation: Navigation | undefined, search = '') {
171+
const objects = objectsWith(navigation);
172+
const dataSource = {
173+
find: vi.fn(async () => ({ data: ROWS, total: ROWS.length })),
174+
findOne: vi.fn(async () => null),
175+
create: vi.fn(async () => ({})),
176+
update: vi.fn(async () => ({})),
177+
delete: vi.fn(async () => ({})),
178+
getObjectSchema: vi.fn(async (name: string) => objects.find((o) => o.name === name) ?? null),
179+
} as never;
180+
window.history.replaceState(null, '', LIST_PATH + search);
181+
render(
182+
<SchemaRendererProvider dataSource={dataSource}>
183+
<MePermissionsProvider initialPermissions={ANSWER}>
184+
<I18nProvider instance={createI18n({ defaultLanguage: 'en', detectBrowserLanguage: false })}>
185+
<ExpressionProvider user={{ id: 'u1', name: 'Ada', profile: 'admin' }}>
186+
<MemoryRouter initialEntries={[LIST_PATH + search]}>
187+
<Routes>
188+
<Route
189+
path="/apps/:appName/:objectName/view/:viewId"
190+
element={
191+
<>
192+
<ObjectView dataSource={dataSource} objects={objects} onEdit={() => {}} />
193+
<LocationProbe />
194+
</>
195+
}
196+
/>
197+
<Route path="*" element={<LocationProbe />} />
198+
</Routes>
199+
</MemoryRouter>
200+
</ExpressionProvider>
201+
</I18nProvider>
202+
</MePermissionsProvider>
203+
</SchemaRendererProvider>,
204+
);
205+
}
206+
207+
const location = () => screen.getByTestId('location').textContent;
208+
209+
/** The phone card showing `title`. */
210+
async function phoneCard(title: string): Promise<HTMLElement> {
211+
const cards = await screen.findAllByTestId('grid-mobile-card', undefined, { timeout: 5000 });
212+
const card = cards.find((c) => (c.textContent ?? '').includes(title));
213+
expect(card).toBeTruthy();
214+
return card as HTMLElement;
215+
}
216+
217+
/** Whether `el` wears a clickable face: the pointer, or a hover wash. */
218+
function looksClickable(el: HTMLElement): boolean {
219+
return /(^|\s)(cursor-pointer|hover:bg-accent\/50)(\s|$)/.test(el.className);
220+
}
221+
222+
describe('objectstack#33719 — on a phone, a list authored to open nothing opens nothing', () => {
223+
it.each(NO_NAVIGATION)('%s: the card is not drawn tappable and a tap opens nothing', async (_name, navigation) => {
224+
mountList(navigation);
225+
const card = await phoneCard('Okta staging');
226+
expect(looksClickable(card)).toBe(false);
227+
const before = location();
228+
fireEvent.click(card);
229+
expect(location()).toBe(before);
230+
expect(location()).not.toContain('/record/');
231+
expect(openSpy).not.toHaveBeenCalled();
232+
});
233+
234+
it.each(NO_NAVIGATION)('%s: a `?recordId=` link opens no record page, as it opens no pane on a desktop', async (_name, navigation) => {
235+
mountList(navigation, '?recordId=c1');
236+
// The list is drawn: the URL-sync effect has run by now.
237+
await phoneCard('Okta staging');
238+
expect(location()).toBe(`${LIST_PATH}?recordId=c1`);
239+
expect(screen.queryByTestId('record-drawer-crumb')).toBeNull();
240+
});
241+
242+
it('CONTROL — a list with no authored navigation: the card wears the pointer and a tap opens the record page', async () => {
243+
mountList(undefined);
244+
const card = await phoneCard('Okta staging');
245+
expect(card.className).toMatch(/(^|\s)cursor-pointer(\s|$)/);
246+
fireEvent.click(card);
247+
await waitFor(() => expect(location()).toContain('/record/c1'));
248+
});
249+
250+
it('CONTROL — a list with no authored navigation: a `?recordId=` link opens the record page', async () => {
251+
mountList(undefined, '?recordId=c1');
252+
await waitFor(() => expect(location()).toContain('/record/c1'), { timeout: 5000 });
253+
});
254+
});

‎ui/packages/app-shell/src/views/objectViewRecordNavigation.ts‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@
2727
* row or a lookup opens above it live in memory, so a reload shows the root.
2828
* Its one `⤢` opens the level shown as the full page (`handleOpenAsPage`).
2929
*
30-
* On a phone (objectstack#27058) none of that applies: the record is always a
31-
* page. The spec's own rule says so (`deriveRecordSurface` with
32-
* `viewport: 'mobile'` answers `page`), a row tap navigates to the record
30+
* On a phone (objectstack#27058) none of that applies: a record that opens
31+
* always opens as a page. The spec's own rule says so (`deriveRecordSurface`
32+
* with `viewport: 'mobile'` answers `page`), a row tap navigates to the record
3333
* route with the list as its origin, and the pane is never mounted, so the
3434
* reader's Open records preference and the drawer's `?recordId=` state do not
3535
* apply: a `?recordId=` link opened on a phone lands on that record's page,
3636
* and the record form the link carries (`?form=`, `?formObject=`,
37-
* `?formLink=`) opens over that page (objectstack#32750).
37+
* `?formLink=`) opens over that page (objectstack#32750). That rule decides
38+
* how a record opens, never whether: an authored `none` (or
39+
* `preventNavigation`) holds on a phone too (objectstack#33719) — a tap opens
40+
* nothing, the card is not drawn as tappable, and a `?recordId=` link opens
41+
* no page, as it opens no pane on a desktop.
3842
*
3943
* An object the server does not read one record of — its served operations
4044
* leave `get` out (`servesRecordRead`), a list-only object — has no record
@@ -233,19 +237,22 @@ export function useObjectViewRecordNavigation({
233237
() => {
234238
// No record surface to open, on any viewport, whatever is authored.
235239
if (!recordServed) return { mode: 'none' };
236-
// objectstack#27058 — on a phone the spec's rule decides, and it
237-
// answers `page` whatever the view or the object declares.
238-
if (phone) return { mode: deriveRecordSurface(objectDef, { viewport: 'mobile' }) as ViewNavigationConfig['mode'] };
239240
const authored = activeView?.navigation ?? objectDef.navigation;
240241
// `preventNavigation: true` ("Disable standard navigation
241242
// entirely") outranks every mode: the row resolves to `none`, so
242243
// no click opens it, a modifier click included, and the list
243244
// draws no link face for it (`rowOpensRecord`, objectstack#33549).
245+
// On every viewport: a phone included (objectstack#33719).
244246
if (authored?.preventNavigation) return { mode: 'none' };
245247
// An authored `none` is "No navigation (read-only list)": rows
246248
// open nothing (objectstack#33548). It outlives the deprecation of
247-
// `navigation.mode` as an open-mode switch (objectstack#35854).
249+
// `navigation.mode` as an open-mode switch (objectstack#35854),
250+
// and the phone rule below, which decides HOW a record opens,
251+
// never WHETHER it does (objectstack#33719).
248252
if (authored?.mode === 'none') return { mode: 'none' };
253+
// objectstack#27058 — on a phone the spec's rule decides how a
254+
// record opens, and it answers `page` whatever else is declared.
255+
if (phone) return { mode: deriveRecordSurface(objectDef, { viewport: 'mobile' }) as ViewNavigationConfig['mode'] };
249256
// objectstack#35854 — `navigation.mode` is deprecated: `drawer`,
250257
// `page` and `new_window` no longer pick how a record opens, so a
251258
// view that declares one behaves as one that declares nothing.
@@ -554,10 +561,13 @@ export function useObjectViewRecordNavigation({
554561
// open: the drawer link is answered by the record's page, in its place in
555562
// the history (objectstack#27058).
556563
// A `?recordId=` link to an object with no record surface opens nothing.
564+
// Nor does one on a list whose rows open nothing (an authored `none` or
565+
// `preventNavigation`): the desktop draws no pane for it, and a phone
566+
// opens no page for it (objectstack#33719).
557567
useEffect(() => {
558568
const openedId = drawerRootServed ? drawerRecordId : null;
559569
if (phone) {
560-
if (!openedId) return;
570+
if (!openedId || detailNavigation.mode === 'none') return;
561571
if (!drawerForeignObject) {
562572
handleNavOverlayNavigate(openedId, undefined, undefined, true);
563573
return;
@@ -572,6 +582,6 @@ export function useObjectViewRecordNavigation({
572582
} else if (!openedId && navOverlay.isOpen) {
573583
navOverlay.close();
574584
}
575-
}, [drawerRecordId, drawerForeignObject, phone, drawerRootServed]);
585+
}, [drawerRecordId, drawerForeignObject, phone, drawerRootServed, detailNavigation.mode]);
576586
return { listRecordActions, navOverlay, drawerWidthKey, handleDrawerClose, handleRowClick, handleOpenAsPage, handleOpenRowInPanel, handleOpenReferencedRecord, drawerRoot, drawerRestore, handleListRowsChange, handleListTotalChange, handleRootStep, listLabel };
577587
}

0 commit comments

Comments
 (0)