From ad4ceb57649551e428de13aed39f03b3af745651 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 02:38:49 +0000 Subject: [PATCH 1/4] =?UTF-8?q?fix(console):=20View=20all=20=E2=86=92=20Ne?= =?UTF-8?q?w=20seeds=20the=20relationship=20lookup's=20dependsOn=20fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The record-trail New on ObjectDataPage wrote the parent formLink pair alone. It now applies relatedCreateSeedOf, the seed the related tab's New writes: the parent record is read once (the trail carries its id only), and only when the relationship lookup declares dependsOn. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6Ca6EBDpTBZk8v46Jjv --- .../37290-view-all-new-dependson-seed.md | 11 ++ .../app-shell/src/views/ObjectDataPage.tsx | 26 ++- ...jectDataPage.viewAllNewSeed-37290.test.tsx | 165 ++++++++++++++++++ 3 files changed, 199 insertions(+), 3 deletions(-) create mode 100644 .changeset/37290-view-all-new-dependson-seed.md create mode 100644 ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx diff --git a/.changeset/37290-view-all-new-dependson-seed.md b/.changeset/37290-view-all-new-dependson-seed.md new file mode 100644 index 00000000000..99c4d70e99d --- /dev/null +++ b/.changeset/37290-view-all-new-dependson-seed.md @@ -0,0 +1,11 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/console': patch +--- + +fix(console): New on a list opened from a related list's "View all" seeds the relationship lookup's `dependsOn` fields, as the related tab's New does + +Clause-②: no +Metadata-protocol: none + +A related list's "View all" opens the child list under the parent record (the record trail). Its New opened the child's create form with the parent link alone, so a relationship lookup that declares `dependsOn` (an order `dependsOn` the account) drew gated ("Select Account first") with the parent hidden, or was emptied by a `lookupAutofill`. It now opens with the same seed the related tab's New writes (`relatedCreateSeedOf`): the parent pair first, then one `formLink` pair per `dependsOn` field, valued from the parent record. The trail holds the parent's id alone, so the page reads the parent record once, and only when the relationship lookup declares a `dependsOn`; a lookup without one, or a parent that cannot be read, opens with the parent link alone, as before. diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.tsx index 18dc548383d..ef3d636976e 100644 --- a/ui/packages/app-shell/src/views/ObjectDataPage.tsx +++ b/ui/packages/app-shell/src/views/ObjectDataPage.tsx @@ -35,6 +35,7 @@ import * as React from 'react'; import { Link, useParams, useNavigate, useSearchParams, useLocation } from 'react-router-dom'; import { ListView, conditionCandidatesOf, conditionOptionsOf, useLookupValueNames } from '@object-ui/plugin-list'; +import { relatedCreateSeedOf } from '@object-ui/plugin-detail/core'; import { useNavigationOverlay, useRowPredicate } from '@object-ui/react'; import { Button, @@ -55,7 +56,7 @@ import { formatMetadataError } from '@object-ui/data-objectstack'; import { useObjectTranslation, useObjectLabel } from '@object-ui/i18n'; import { usePermissions, useFieldPermissions } from '@object-ui/permissions'; import { useAuth, useWorkspaceAdminStatus } from '@object-ui/auth'; -import { optionDisplayLabel, resolveAffordance, resolveFilterPlaceholders, type SchemaLike } from '@object-ui/core'; +import { optionDisplayLabel, parentRelationshipFieldDef, resolveAffordance, resolveFilterPlaceholders, type SchemaLike } from '@object-ui/core'; import { normalizeFilterOperator, ViewFilterRuleSchema } from '@objectstack/spec/ui'; import type { ViewFilterRule } from '@objectstack/spec/ui'; import { @@ -961,8 +962,27 @@ export function ObjectDataPage({ dataSource, objects }: any) { const sp = new URLSearchParams(searchParams); sp.set(RECORD_FORM_PARAM, 'new'); sp.set(RECORD_FORM_OBJECT_PARAM, objectDef.name); - sp.set(RECORD_FORM_LINK_PARAM, `${sourceField}:${source.i}`); - setSearchParams(sp); + sp.delete(RECORD_FORM_LINK_PARAM); + sp.append(RECORD_FORM_LINK_PARAM, `${sourceField}:${source.i}`); + // objectstack#37290 — and seeded as the related tab's New seeds it + // (objectstack#37246): each `dependsOn` field of the link takes the + // source record's value, or the form gates the lookup. The trail + // carries the record's id alone, so the record is read once, and + // only when the link declares a `dependsOn` to seed. + const dependsOn = (parentRelationshipFieldDef(objectDef.fields, sourceField) as { dependsOn?: unknown } | undefined)?.dependsOn; + const open = (parentRecord?: Record) => { + for (const [field, value] of Object.entries(relatedCreateSeedOf(objectDef.fields, sourceField, parentRecord))) { + sp.append(RECORD_FORM_LINK_PARAM, `${field}:${value}`); + } + setSearchParams(sp); + }; + if (Array.isArray(dependsOn) && dependsOn.length > 0 && typeof dataSource?.findOne === 'function') { + Promise.resolve(dataSource.findOne(source.o, source.i)) + .then((rec: unknown) => open(rec && typeof rec === 'object' ? (rec as Record) : undefined)) + .catch(() => open(undefined)); + return; + } + open(undefined); return; } navigate('../new', { relative: 'path' }); diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx new file mode 100644 index 00000000000..365b7e04d44 --- /dev/null +++ b/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx @@ -0,0 +1,165 @@ +/** + * 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#37290 — New on a list opened from a related list's "View all" + * (the record trail, objectstack#35601) seeds the child as the related tab's + * New does (objectstack#37246, `relatedCreateSeedOf`): beside the parent pair, + * each `dependsOn` field of the link takes the source record's value. The + * trail holds the record's id alone, so the page reads the record once. + * + * Control: a link with no `dependsOn` writes the parent pair and reads nothing. + */ + +import * as React from 'react'; +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { render, cleanup, fireEvent, screen, waitFor } from '@testing-library/react'; +import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom'; +// The page reaches `@objectstack/lint` through a dynamic import; its first load is paid at collection, not inside a case. +import '@objectstack/lint'; + +vi.mock('@object-ui/permissions', async (importOriginal) => { + const actual = await importOriginal(); + return { + ...actual, + usePermissions: () => ({ + check: () => ({ allowed: true }), + checkField: () => true, + getFieldPermissions: () => [], + getRowFilter: () => undefined, + getObjectApiOperations: () => undefined, + roles: [], + isLoaded: false, + hasCapabilities: () => true, + can: () => true, + cannot: () => false, + }), + useFieldPermissions: () => ({ canRead: () => true, canWrite: () => true, permissions: [] }), + }; +}); + +vi.mock('@object-ui/auth', async (importOriginal) => ({ + ...(await importOriginal>()), + useAuth: () => ({ user: { id: 'u1', name: 'Ada' }, activeOrganization: null }), + useWorkspaceAdminStatus: () => ({ isAdmin: false, isResolved: true }), + createAuthenticatedFetch: () => vi.fn(), +})); + +// Heavy children, all orthogonal to the New path under test and each dragging in +// a plugin bundle — the same posture as the sibling create-affordance test on +// this page. +vi.mock('@object-ui/plugin-list', async (importOriginal) => ({ + ...(await importOriginal()), + ListView: () => null, +})); +vi.mock('./RecordDetailView', () => ({ RecordDetailView: () => null })); +vi.mock('./CreateViewDialog', () => ({ CreateViewDialog: () => null })); +vi.mock('./metadata-admin/useMetadata', () => ({ useMetadataClient: () => ({}) })); + +import { ObjectDataPage } from './ObjectDataPage'; +import { ExpressionProvider } from '../providers/ExpressionProvider'; +import { RECORD_TRAIL_PARAM } from '../urlParams'; + +const h = React.createElement; + +const OBJECTS = [ + { + name: 'contract', + label: 'Contract', + pluralLabel: 'Contracts', + managedBy: 'platform', + fields: { + id: { type: 'text', label: 'Id' }, + account: { type: 'lookup', reference: 'account', label: 'Account' }, + opportunity: { type: 'lookup', reference: 'opportunity', label: 'Opportunity', dependsOn: ['account'] }, + }, + }, + { + name: 'task', + label: 'Task', + pluralLabel: 'Tasks', + managedBy: 'platform', + fields: { + id: { type: 'text', label: 'Id' }, + opportunity: { type: 'lookup', reference: 'opportunity', label: 'Opportunity' }, + }, + }, + { name: 'opportunity', label: 'Opportunity', pluralLabel: 'Opportunities', managedBy: 'platform', fields: { name: { type: 'text', label: 'Name' }, account: { type: 'lookup', reference: 'account', label: 'Account' } } }, + { name: 'account', label: 'Account', pluralLabel: 'Accounts', managedBy: 'platform', fields: { name: { type: 'text', label: 'Name' } } }, +]; + +const TRAIL = encodeURIComponent(JSON.stringify([{ o: 'opportunity', i: 'O-1', t: 'Big deal' }])); + +function makeDataSource() { + return { + find: vi.fn(async () => ({ data: [], total: 0 })), + findOne: vi.fn(async (object: string, id: string) => (object === 'opportunity' && id === 'O-1' ? { id: 'O-1', name: 'Big deal', account: 'A-1' } : null)), + create: vi.fn(async () => ({})), + update: vi.fn(async () => ({})), + delete: vi.fn(async () => ({})), + } as any; +} + +function Probe() { + const location = useLocation(); + return h('output', { 'data-testid': 'probe' }, `${location.pathname}${location.search}`); +} + +function renderAt(objectName: string, dataSource: any) { + return render( + h(ExpressionProvider, { + user: { id: 'u1', name: 'Ada', profile: 'admin' }, + children: h( + MemoryRouter, + { initialEntries: [`/apps/demo/${objectName}/data?filter[opportunity]=O-1&${RECORD_TRAIL_PARAM}=${TRAIL}`] }, + h(Routes, null, h(Route, { + path: '/apps/:appName/:objectName/data', + element: h(React.Fragment, null, h(ObjectDataPage, { dataSource, objects: OBJECTS }), h(Probe)), + })), + ), + }), + ); +} + +const params = () => new URLSearchParams((screen.getByTestId('probe').textContent ?? '').split('?')[1] ?? ''); +const clickNew = () => fireEvent.click(document.querySelector('[data-testid="object-data-new-button"]')!); + +beforeEach(() => { + cleanup(); + vi.stubGlobal('fetch', vi.fn(async () => new Response(JSON.stringify({ data: [] }), { + status: 200, + headers: { 'content-type': 'application/json' }, + }))); +}); + +afterEach(() => { + vi.unstubAllGlobals(); + vi.clearAllMocks(); +}); + +describe('New from a record trail seeds the dependsOn fields (objectstack#37290)', () => { + it('opens the child form with the parent pair, then the dependsOn value read from the source record', async () => { + const ds = makeDataSource(); + renderAt('contract', ds); + clickNew(); + await waitFor(() => expect(params().get('form')).toBe('new')); + expect(params().get('formObject')).toBe('contract'); + expect(params().getAll('formLink')).toEqual(['opportunity:O-1', 'account:A-1']); + expect(ds.findOne).toHaveBeenCalledTimes(1); + expect(ds.findOne).toHaveBeenCalledWith('opportunity', 'O-1'); + }); + + it('CONTROL — a link with no dependsOn writes the parent pair alone and reads nothing', async () => { + const ds = makeDataSource(); + renderAt('task', ds); + clickNew(); + await waitFor(() => expect(params().get('form')).toBe('new')); + expect(params().getAll('formLink')).toEqual(['opportunity:O-1']); + expect(ds.findOne).not.toHaveBeenCalledWith('opportunity', 'O-1'); + }); +}); From fe65dac8be85f9f17b9d413a0e9c027240284891 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 04:45:12 +0000 Subject: [PATCH 2/4] =?UTF-8?q?fix(console):=20View=20all=20=E2=86=92=20Ne?= =?UTF-8?q?w=20shows=20a=20pending=20state,=20bounds=20the=20parent=20read?= =?UTF-8?q?=20and=20drops=20a=20stale=20result?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The record-trail New reads the parent before opening the form when the link declares dependsOn. While it reads, New is disabled and aria-busy; the read is bounded (TRAIL_NEW_PARENT_READ_TIMEOUT_MS), past which the form opens with the parent link alone; a read that settles after the page unmounted or the address moved on opens nothing. Pins the refused, empty, hung and stale arms. Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6Ca6EBDpTBZk8v46Jjv --- .../app-shell/src/views/ObjectDataPage.tsx | 37 ++++++++- ...jectDataPage.viewAllNewSeed-37290.test.tsx | 75 +++++++++++++++++-- 2 files changed, 102 insertions(+), 10 deletions(-) diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.tsx index ef3d636976e..8588fae7510 100644 --- a/ui/packages/app-shell/src/views/ObjectDataPage.tsx +++ b/ui/packages/app-shell/src/views/ObjectDataPage.tsx @@ -324,6 +324,13 @@ function addressPanelFilterConditionCount(searchParams: URLSearchParams): number return Array.isArray(conditions) ? conditions.length : 0; } +/** + * objectstack#37290 — how long New under a record trail waits for the parent + * read its `dependsOn` seed needs. Past it the form opens with the parent link + * alone, as it does when the read is refused or finds nothing. + */ +export const TRAIL_NEW_PARENT_READ_TIMEOUT_MS = 5000; + export function ObjectDataPage({ dataSource, objects }: any) { const { appName, objectName } = useParams(); const { t, language } = useObjectTranslation(); @@ -908,6 +915,12 @@ export function ObjectDataPage({ dataSource, objects }: any) { label: 'builtin:create:disabledWhen', }); const createDisabled = createPredicates?.disabledWhen != null && createDisabledPred; + // objectstack#37290 — New under a record trail may read the parent first + // (the `dependsOn` seed). While it does, New is pending; a click's result is + // dropped when the page unmounted or the address moved on before it settled. + const [newPending, setNewPending] = React.useState(false); + const newClickRef = React.useRef(0); + React.useEffect(() => () => { newClickRef.current += 1; }, []); if (!objectDef) { return ( @@ -977,9 +990,24 @@ export function ObjectDataPage({ dataSource, objects }: any) { setSearchParams(sp); }; if (Array.isArray(dependsOn) && dependsOn.length > 0 && typeof dataSource?.findOne === 'function') { - Promise.resolve(dataSource.findOne(source.o, source.i)) - .then((rec: unknown) => open(rec && typeof rec === 'object' ? (rec as Record) : undefined)) - .catch(() => open(undefined)); + const click = ++newClickRef.current; + const at = `${location.pathname}${location.search}`; + setNewPending(true); + let timer: ReturnType | undefined; + const timedOut = new Promise((resolve) => { + timer = setTimeout(() => resolve(undefined), TRAIL_NEW_PARENT_READ_TIMEOUT_MS); + }); + const read = Promise.resolve() + .then(() => dataSource.findOne(source.o, source.i)) + .catch(() => undefined); + void Promise.race([read, timedOut]).then((rec: unknown) => { + clearTimeout(timer); + if (click !== newClickRef.current) return; + setNewPending(false); + const now = locationRef.current; + if (`${now.pathname}${now.search}` !== at) return; + open(rec && typeof rec === 'object' ? (rec as Record) : undefined); + }); return; } open(undefined); @@ -987,7 +1015,8 @@ export function ObjectDataPage({ dataSource, objects }: any) { } navigate('../new', { relative: 'path' }); }} - disabled={createDisabled} + disabled={createDisabled || newPending} + aria-busy={newPending || undefined} className="shadow-none gap-1.5 h-8 sm:h-9" data-testid="object-data-new-button" > diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx index 365b7e04d44..773d17de7b9 100644 --- a/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx @@ -14,12 +14,15 @@ * trail holds the record's id alone, so the page reads the record once. * * Control: a link with no `dependsOn` writes the parent pair and reads nothing. + * A read refused, empty or past `TRAIL_NEW_PARENT_READ_TIMEOUT_MS` opens the + * form with the parent pair alone; New is pending while the read runs; a read + * that settles after the address moved on opens nothing. */ import * as React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { render, cleanup, fireEvent, screen, waitFor } from '@testing-library/react'; -import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom'; +import { MemoryRouter, Routes, Route, useLocation, useNavigate } from 'react-router-dom'; // The page reaches `@objectstack/lint` through a dynamic import; its first load is paid at collection, not inside a case. import '@objectstack/lint'; @@ -61,7 +64,7 @@ vi.mock('./RecordDetailView', () => ({ RecordDetailView: () => null })); vi.mock('./CreateViewDialog', () => ({ CreateViewDialog: () => null })); vi.mock('./metadata-admin/useMetadata', () => ({ useMetadataClient: () => ({}) })); -import { ObjectDataPage } from './ObjectDataPage'; +import { ObjectDataPage, TRAIL_NEW_PARENT_READ_TIMEOUT_MS } from './ObjectDataPage'; import { ExpressionProvider } from '../providers/ExpressionProvider'; import { RECORD_TRAIL_PARAM } from '../urlParams'; @@ -95,10 +98,13 @@ const OBJECTS = [ const TRAIL = encodeURIComponent(JSON.stringify([{ o: 'opportunity', i: 'O-1', t: 'Big deal' }])); -function makeDataSource() { +const readParent = async (object: string, id: string) => + (object === 'opportunity' && id === 'O-1' ? { id: 'O-1', name: 'Big deal', account: 'A-1' } : null); + +function makeDataSource(findOne: (object: string, id: string) => Promise = readParent) { return { find: vi.fn(async () => ({ data: [], total: 0 })), - findOne: vi.fn(async (object: string, id: string) => (object === 'opportunity' && id === 'O-1' ? { id: 'O-1', name: 'Big deal', account: 'A-1' } : null)), + findOne: vi.fn(findOne), create: vi.fn(async () => ({})), update: vi.fn(async () => ({})), delete: vi.fn(async () => ({})), @@ -110,6 +116,13 @@ function Probe() { return h('output', { 'data-testid': 'probe' }, `${location.pathname}${location.search}`); } +/** Moves the address on (a filter change made while New's read is pending). */ +function Mover() { + const navigate = useNavigate(); + const location = useLocation(); + return h('button', { 'data-testid': 'move', onClick: () => navigate(`${location.pathname}${location.search}&moved=1`) }, 'move'); +} + function renderAt(objectName: string, dataSource: any) { return render( h(ExpressionProvider, { @@ -119,7 +132,7 @@ function renderAt(objectName: string, dataSource: any) { { initialEntries: [`/apps/demo/${objectName}/data?filter[opportunity]=O-1&${RECORD_TRAIL_PARAM}=${TRAIL}`] }, h(Routes, null, h(Route, { path: '/apps/:appName/:objectName/data', - element: h(React.Fragment, null, h(ObjectDataPage, { dataSource, objects: OBJECTS }), h(Probe)), + element: h(React.Fragment, null, h(ObjectDataPage, { dataSource, objects: OBJECTS }), h(Probe), h(Mover)), })), ), }), @@ -127,7 +140,8 @@ function renderAt(objectName: string, dataSource: any) { } const params = () => new URLSearchParams((screen.getByTestId('probe').textContent ?? '').split('?')[1] ?? ''); -const clickNew = () => fireEvent.click(document.querySelector('[data-testid="object-data-new-button"]')!); +const newButton = () => document.querySelector('[data-testid="object-data-new-button"]') as HTMLButtonElement; +const clickNew = () => fireEvent.click(newButton()); beforeEach(() => { cleanup(); @@ -138,6 +152,7 @@ beforeEach(() => { }); afterEach(() => { + vi.useRealTimers(); vi.unstubAllGlobals(); vi.clearAllMocks(); }); @@ -162,4 +177,52 @@ describe('New from a record trail seeds the dependsOn fields (objectstack#37290) expect(params().getAll('formLink')).toEqual(['opportunity:O-1']); expect(ds.findOne).not.toHaveBeenCalledWith('opportunity', 'O-1'); }); + + it('a refused parent read opens the form with the parent pair alone', async () => { + const ds = makeDataSource(async () => { throw Object.assign(new Error('forbidden'), { status: 403 }); }); + renderAt('contract', ds); + clickNew(); + await waitFor(() => expect(params().get('form')).toBe('new')); + expect(params().getAll('formLink')).toEqual(['opportunity:O-1']); + expect(ds.findOne).toHaveBeenCalledWith('opportunity', 'O-1'); + expect(newButton().disabled).toBe(false); + }); + + it('a parent read that finds nothing opens the form with the parent pair alone', async () => { + const ds = makeDataSource(async () => null); + renderAt('contract', ds); + clickNew(); + await waitFor(() => expect(params().get('form')).toBe('new')); + expect(params().getAll('formLink')).toEqual(['opportunity:O-1']); + expect(ds.findOne).toHaveBeenCalledWith('opportunity', 'O-1'); + }); + + it('New is pending while the read runs, and a read that never settles opens the parent pair alone after the bound', async () => { + vi.useFakeTimers({ shouldAdvanceTime: true }); + const ds = makeDataSource(() => new Promise(() => {})); + renderAt('contract', ds); + clickNew(); + await waitFor(() => expect(newButton().disabled).toBe(true)); + expect(newButton().getAttribute('aria-busy')).toBe('true'); + expect(params().get('form')).toBeNull(); + await vi.advanceTimersByTimeAsync(TRAIL_NEW_PARENT_READ_TIMEOUT_MS); + await waitFor(() => expect(params().get('form')).toBe('new')); + expect(params().getAll('formLink')).toEqual(['opportunity:O-1']); + expect(newButton().disabled).toBe(false); + }); + + it('a read that settles after the address moved on opens nothing and keeps the new address', async () => { + let settle: (rec: unknown) => void = () => {}; + const ds = makeDataSource(() => new Promise((resolve) => { settle = resolve; })); + renderAt('contract', ds); + clickNew(); + await waitFor(() => expect(newButton().disabled).toBe(true)); + fireEvent.click(screen.getByTestId('move')); + await waitFor(() => expect(params().get('moved')).toBe('1')); + settle({ id: 'O-1', account: 'A-1' }); + await waitFor(() => expect(newButton().disabled).toBe(false)); + expect(params().get('form')).toBeNull(); + expect(params().getAll('formLink')).toEqual([]); + expect(params().get('moved')).toBe('1'); + }); }); From 5f39581f1cc6904260f74c73e767fea2d0ab3104 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 04:51:08 +0000 Subject: [PATCH 3/4] test(console): the stale-read pin lets a late write land before reading the address Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6Ca6EBDpTBZk8v46Jjv --- .../src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx index 773d17de7b9..327fea10529 100644 --- a/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectDataPage.viewAllNewSeed-37290.test.tsx @@ -21,7 +21,7 @@ import * as React from 'react'; import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; -import { render, cleanup, fireEvent, screen, waitFor } from '@testing-library/react'; +import { render, cleanup, fireEvent, screen, waitFor, act } from '@testing-library/react'; import { MemoryRouter, Routes, Route, useLocation, useNavigate } from 'react-router-dom'; // The page reaches `@objectstack/lint` through a dynamic import; its first load is paid at collection, not inside a case. import '@objectstack/lint'; @@ -219,8 +219,11 @@ describe('New from a record trail seeds the dependsOn fields (objectstack#37290) await waitFor(() => expect(newButton().disabled).toBe(true)); fireEvent.click(screen.getByTestId('move')); await waitFor(() => expect(params().get('moved')).toBe('1')); + expect(newButton().disabled, 'still pending after the move (same mount)').toBe(true); settle({ id: 'O-1', account: 'A-1' }); await waitFor(() => expect(newButton().disabled).toBe(false)); + // A stale open would write the address after the pending flag clears: let it land before reading. + await act(async () => { await new Promise((resolve) => setTimeout(resolve, 50)); }); expect(params().get('form')).toBeNull(); expect(params().getAll('formLink')).toEqual([]); expect(params().get('moved')).toBe('1'); From 90c47a7a633aab768f585c42cef6dc0ec079a06b Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 04:51:38 +0000 Subject: [PATCH 4/4] =?UTF-8?q?docs(changeset):=20View=20all=20=E2=86=92?= =?UTF-8?q?=20New=20pending=20state,=20read=20bound=20and=20stale=20drop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6Ca6EBDpTBZk8v46Jjv --- .changeset/37290-view-all-new-dependson-seed.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/37290-view-all-new-dependson-seed.md b/.changeset/37290-view-all-new-dependson-seed.md index 99c4d70e99d..f91f1808b22 100644 --- a/.changeset/37290-view-all-new-dependson-seed.md +++ b/.changeset/37290-view-all-new-dependson-seed.md @@ -8,4 +8,4 @@ fix(console): New on a list opened from a related list's "View all" seeds the re Clause-②: no Metadata-protocol: none -A related list's "View all" opens the child list under the parent record (the record trail). Its New opened the child's create form with the parent link alone, so a relationship lookup that declares `dependsOn` (an order `dependsOn` the account) drew gated ("Select Account first") with the parent hidden, or was emptied by a `lookupAutofill`. It now opens with the same seed the related tab's New writes (`relatedCreateSeedOf`): the parent pair first, then one `formLink` pair per `dependsOn` field, valued from the parent record. The trail holds the parent's id alone, so the page reads the parent record once, and only when the relationship lookup declares a `dependsOn`; a lookup without one, or a parent that cannot be read, opens with the parent link alone, as before. +A related list's "View all" opens the child list under the parent record (the record trail). Its New opened the child's create form with the parent link alone, so a relationship lookup that declares `dependsOn` (an order `dependsOn` the account) drew gated ("Select Account first") with the parent hidden, or was emptied by a `lookupAutofill`. It now opens with the same seed the related tab's New writes (`relatedCreateSeedOf`): the parent pair first, then one `formLink` pair per `dependsOn` field, valued from the parent record. The trail holds the parent's id alone, so the page reads the parent record once, and only when the relationship lookup declares a `dependsOn`; a lookup without one, or a parent that cannot be read, opens with the parent link alone, as before. While the parent is read, New is disabled; a read that has not answered within 5 seconds opens the form with the parent link alone, and a read that answers after the page moved on (another filter, another page) opens nothing.