Skip to content

Commit 0abdf3a

Browse files
committed
fix(plugin-grid): a bulk action param never carries the record-form stamp onto its widget
bulkParamToField forwarded every unenumerated param key, so a bulk param that wrote recordBeingEdited itself opted its lookup into { $record } resolution against the sibling params. The key is dropped; paramToField already builds the field from enumerated keys. Both dialog pins gain the case. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ADHkmTKRu1t68jcJGgRYi3
1 parent 0179f34 commit 0abdf3a

3 files changed

Lines changed: 73 additions & 4 deletions

File tree

‎ui/packages/app-shell/src/views/ActionParamDialog.recordReference-34197.test.tsx‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
* record a `{ $record: 'quote_date' }` path names. The picker resolves a
1717
* reference only on a field a record form stamped (`withRecordBeingEdited`);
1818
* `paramToField` builds the widget field from enumerated keys and stamps
19-
* nothing. Driven through the real `ActionParamDialog`.
19+
* nothing, so a param that writes `recordBeingEdited` itself is not let opt
20+
* in either. Driven through the real `ActionParamDialog`.
2021
*
2122
* CONTROL: the literal entry beside it reaches the candidate query, so the
2223
* dialog does forward `lookupFilters` — the missing entry is left out, not
@@ -47,7 +48,33 @@ const PRICE_BOOK: ActionParamDef = {
4748
],
4849
} as ActionParamDef;
4950

51+
async function pickerQueries(priceBook: ActionParamDef) {
52+
const ds = {
53+
find: vi.fn(async () => ({ data: [{ id: 'b1', name: 'Standard 2026' }], total: 1 })),
54+
findOne: vi.fn(async () => null),
55+
};
56+
render(
57+
<SchemaRendererProvider dataSource={ds as never}>
58+
<ActionParamDialog state={{ open: true, params: [QUOTE_DATE, priceBook], resolve: () => {} }} onOpenChange={() => {}} />
59+
</SchemaRendererProvider>,
60+
);
61+
fireEvent.change(await screen.findByLabelText('Quote date'), { target: { value: '2026-11-01' } });
62+
const trigger = await screen.findByTestId('lookup-trigger-price_book');
63+
await act(async () => {
64+
fireEvent.click(trigger);
65+
});
66+
const queries = () => ds.find.mock.calls.filter((c: any[]) => c[0] === 'price_book').map((c: any[]) => c[1]?.$filter);
67+
await waitFor(() => expect(queries().length).toBeGreaterThan(0));
68+
return { queries: queries(), ds };
69+
}
70+
5071
describe('ActionParamDialog — a { $record } lookup filter is left out (objectstack#34197)', () => {
72+
it('a param that writes the record-form stamp itself gains nothing: the entry is still left out', async () => {
73+
const { queries, ds } = await pickerQueries({ ...PRICE_BOOK, recordBeingEdited: { hopObjects: {} } } as ActionParamDef);
74+
for (const filter of queries) expect(filter).toEqual({ is_active: true });
75+
expect(ds.findOne).not.toHaveBeenCalled();
76+
});
77+
5178
it('leaves the entry out although a sibling param holds a value of that name', async () => {
5279
const ds = {
5380
find: vi.fn(async () => ({ data: [{ id: 'b1', name: 'Standard 2026' }], total: 1 })),

‎ui/packages/plugin-grid/src/__tests__/bulkActionDialogRecordReference-34197.test.tsx‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* dialog stamps nothing. Driven through the real `BulkActionDialog`, because
1919
* the hand-off of the sibling values IS the hazard.
2020
*
21+
* A param that writes `recordBeingEdited` itself is not let opt in:
22+
* `bulkParamToField` never carries the key from a param.
23+
*
2124
* CONTROL: the literal entry beside it reaches the candidate query, so the
2225
* dialog does forward `lookupFilters` — the missing entry is left out, not
2326
* lost with the rest.
@@ -55,7 +58,40 @@ const PRICE_BOOK = {
5558
],
5659
};
5760

61+
async function pickerQueries(priceBook: Record<string, unknown>) {
62+
const ds = makeDataSource();
63+
render(
64+
<BulkActionDialog
65+
def={{ name: 'bulk_reprice', label: 'Reprice', operation: 'update', params: [QUOTE_DATE, priceBook] } as any}
66+
rows={[{ id: 'r1' }, { id: 'r2' }]}
67+
resource="quote"
68+
dataSource={ds}
69+
open
70+
onClose={() => {}}
71+
/>,
72+
);
73+
const dateInput = await waitFor(() => {
74+
const el = document.getElementById('bulk-param-quote_date');
75+
if (!el) throw new Error('dialog not ready');
76+
return el;
77+
});
78+
fireEvent.change(dateInput, { target: { value: '2026-11-01' } });
79+
const trigger = await screen.findByTestId('lookup-trigger-price_book');
80+
await act(async () => {
81+
fireEvent.click(trigger);
82+
});
83+
const queries = () => ds.find.mock.calls.filter((c: any[]) => c[0] === 'price_book').map((c: any[]) => c[1]?.$filter);
84+
await waitFor(() => expect(queries().length).toBeGreaterThan(0));
85+
return { queries: queries(), ds };
86+
}
87+
5888
describe('BulkActionDialog — a { $record } lookup filter is left out (objectstack#34197)', () => {
89+
it('a param that writes the record-form stamp itself gains nothing: the entry is still left out', async () => {
90+
const { queries, ds } = await pickerQueries({ ...PRICE_BOOK, recordBeingEdited: { hopObjects: {} } });
91+
for (const filter of queries) expect(filter).toEqual({ is_active: true });
92+
expect(ds.findOne).not.toHaveBeenCalled();
93+
});
94+
5995
it('leaves the entry out although a sibling param holds a value of that name', async () => {
6096
const ds = makeDataSource();
6197
render(

‎ui/packages/plugin-grid/src/components/bulkParamToField.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* `paramToField`).
2323
*/
2424
import { EXPANDABLE_FIELD_TYPES } from '@object-ui/core';
25-
import { resolveFormWidgetType } from '@object-ui/fields';
25+
import { RECORD_BEING_EDITED_KEY, resolveFormWidgetType } from '@object-ui/fields';
2626
import type { BulkActionParam } from '@object-ui/types';
2727

2828
/**
@@ -123,7 +123,10 @@ export function lookupTargetObject(param: BulkActionParam): string | undefined {
123123
* bulk person params get the exact PeoplePicker the form's user fields use
124124
* (search-first, avatar + department·email rows, banned users excluded).
125125
* - `BulkActionParam`'s documented catch-all keys (min/max/step/format/…) are
126-
* forwarded to the widget as-is.
126+
* forwarded to the widget as-is — except `recordBeingEdited`, which only a
127+
* record form may stamp (`withRecordBeingEdited`): this dialog edits no
128+
* single record, so a param that writes the key itself is not let opt its
129+
* lookup into `{ $record }` resolution against the sibling params.
127130
*/
128131
export function bulkParamToField(
129132
param: BulkActionParam,
@@ -160,8 +163,11 @@ export function bulkParamToField(
160163
object,
161164
labelField,
162165
placeholder,
166+
// Never carried: the host's statement that one record is being edited,
167+
// which this dialog cannot make (objectstack#34197).
168+
[RECORD_BEING_EDITED_KEY]: _recordBeingEdited,
163169
...extra
164-
} = param;
170+
} = param as BulkActionParam & { [RECORD_BEING_EDITED_KEY]?: unknown };
165171

166172
const field: Record<string, any> = {
167173
...extra,

0 commit comments

Comments
 (0)