Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 67d4ed9

Browse files
fix(plugin-gantt): an EMPTY host data array is "no host rows yet", not the rows (objectui#7333) (#10812)
Fixes #7333 Clause-②: no (copied from the claim): the gantt stops treating an empty host array as authoritative. It keeps fetching from the view's own source, as it does with no host array at all; no declared key, export or accept set moves. ## What changed `ObjectGantt` read a host `data` prop at two sites, and both accepted `[]`: - the short-circuit at the head of `reload` tested `data && Array.isArray(data)`. `[]` is truthy, so the chart adopted it and returned before its own query; - the gating flag (`hasHostData`, a bare `Array.isArray(data)`) fed `recordQueryDerivesExpand`, so the same `[]` also switched off the object-schema gate and the data-invalidation subscription of the query the chart should still issue. Both sites now read ONE predicate, `hostRows`, evaluated once per render: a host array counts only when it has rows. An empty one reads as "no host rows yet", and the chart reads from its own source exactly as it does with no host array at all. A non-empty host array is adopted as before. `reload` reads the predicate through `hostRowsRef` instead of closing over `rest`. `reload` does not key on the host rows, so a closed-over value is the one from whichever render last rebuilt `reload`. When a host's rows arrive after an empty first render, `recordQueryDerivesExpand` flips and re-fires the fetch effect, and that run has to see the rows that flipped it. Ablation A3 below shows that the closure form gets this wrong. The `eslint-disable` reason on `reload`'s dependency list said `(rest as any).data intentionally untracked`, which is no longer true. It now names what it actually suppresses, `searchFields`, measured by linting the file with the directive stripped: base reports `rest` and `searchFields`, head reports `searchFields` only. ## Which gate, and why (objectui#7210 half 2, ruling a′, PR #7391) The card left this open: gate on length, or on an explicit "the host owns the rows" signal. Its routing note said the length gate is enough if the wrapper does not forward host props. Ruling a′ lets a non-grid view fetch the whole filtered set up to a platform ceiling, and PR #7391 implemented it with the `object-gantt` renderer still forwarding nothing. Its "Not in this PR" section calls forwarding `data` "the explicitly fenced-off wrong fix". So no host owns a gantt's rows on the registry path, and none is planned. Adding a host-ownership signal would be a new prop contract with nothing pulling for it. **The length gate is therefore the one that matches the ruling.** ## Premise and reach (measured on `6cf599985`) - **Both sites existed as the card and triage describe them.** Base run of the new pins: `Tests 3 failed | 2 passed (5)`. Only the two controls pass. - **Reach: no caller hands `ObjectGantt` a `data` prop today.** `ObjectGanttRenderer` (`index.tsx`) still destructures only `schema` and renders `ObjectGantt` with `schema` and `dataSource`, and `ObjectGantt.hostDataProp-7210.test.tsx` pins that. A tree-wide `git grep` for direct JSX uses of `ObjectGantt` outside tests turns up `index.tsx` and `demo/main.tsx`, both passing only `schema` and `dataSource`, plus the README and docs examples, which pass `schema`, `dataSource` and `onTaskClick`. `ObjectGanttProps` does not declare `data`, so a typed caller can only reach this through a cast or an untyped spread, which is how the existing tests do it. ⇒ **This hardens a published component's input. It does not fix a live defect.** The triage ruled it owed anyway. - **`ListView`'s rows array for an api-provider gantt view:** `useState` starts it as `[]`, and the fetch effect's `ganttOwnsData` branch returns without writing it. So from mount it is exactly the `[]` this card is about. `ListView` withholds it from the chart, which is unchanged here. ## Surface note: two plugin-list comments corrected (outside the claimed file surface) My change made two comments false, so I corrected them. Both are comment-only, with no code bytes changed: - `packages/plugin-list/src/ListView.tsx`, the `ganttOwnsData` block, said the chart short-circuits on `[]` and that forwarding would paint an EMPTY chart; - `packages/plugin-list/src/__tests__/ListView.test.tsx`, the comment on the api-provider gantt `describe`, said the same. Both now say that an empty host array no longer blanks the chart and that the withholding still guards against a non-empty array being adopted in place of the endpoint's rows. `ObjectGanttRenderer` and the `persistLayoutKey` comment are untouched, as the claim requires. ## Tests New file `packages/plugin-gantt/src/ObjectGantt.emptyHostData-7333.test.tsx`, five cases: 1. api provider + host `data: []`: the endpoint is read and its rows paint; 2. CONTROL, api provider + host rows: those rows paint and the endpoint is never read; 3. CONTROL, api provider + no host `data`: the endpoint is read; 4. host rows that arrive after an empty first render are adopted; 5. object provider + host `data: []`: ONE query, issued after the schema settles, already carrying `$expand` (this pins the gating-flag site). **Ablation**, run once with a prediction written before each run. Mutations go through `ablation-replace` WRAP mode: the anchor hit once, the blob moved, the restore was proven against the HEAD blob, and `git diff HEAD` was empty after each leg. Tests import `./ObjectGantt` relatively, so the resolution path is `src` and no build is involved. | leg | mutation | predicted | observed | |---|---|---|---| | A1 | reload's site back to "any array" | 3 failed / 2 passed | `Tests 3 failed \| 2 passed (5)` | | A2 | gating flag back to a bare `Array.isArray` | 2 failed / 3 passed (cases 4, 5) | `Tests 2 failed \| 3 passed (5)` | | A3 | reload reads the closed-over `hostRows`, not the ref | 1 failed / 4 passed (case 4) | `Tests 1 failed \| 4 passed (5)` | ## Local gates, all at HEAD `404ea62` - `vitest run --maxWorkers=2 packages/plugin-gantt/ packages/plugin-list/src/__tests__/ListView.test.tsx`: `Test Files 83 passed (83)`, `Tests 764 passed (764)`, lock `VERDICT command-exit 0`. That is 82 plugin-gantt test files plus `ListView.test.tsx`. - `pnpm --filter @object-ui/plugin-gantt type-check` (`tsc --noEmit && tsc -p tsconfig.test.json`): `TYPECHECK_EXIT=0`, after building the `@object-ui/plugin-gantt^...` closure (`Tasks: 12 successful, 12 total`). `--listFilesOnly` on the test program shows the new test file and 82 test files in it. - plugin-list type-check was not re-run: the plugin-list diff is comment-only. - `check-changeset-presence`: `✅ 4 source file(s) of 2 released package(s) changed, and this change declares 1 changeset(s)`. - `check-changeset-fixed` and `check-changeset-no-major`: ✅. - `check:changeset-claims` (report-only): 9 pending changesets name `ObjectGantt.tsx` or `ListView.tsx`. I read each paragraph, and none describes the host-data short-circuit. - `check:pending-changeset-literals`, `check:control-bytes`, `check:vi-mock-specifiers`, `check:vi-mock-inherit`, `check:vi-mock-override-shape`, `check:test-path-roots`, `check:unreferenced-sources`: all OK. - `check:new-line-citations`: `VERDICT new-cross-file-line-citations: 0 new citation(s)`. - `node scripts/check-governed-queue-guard.mjs --test` on the 5 paths: `✅ NOT GOVERNED`. - **Lint, narrowed to the changed files and proven complete.** - Population: `pnpm lint` is each package's `eslint .`, and the root `lint:root` ignores `packages/*`. So the changed files are linted by the plugin-gantt and plugin-list configs. - Count: `eslint --format json` reports 2 + 2 files, 0 errors, 0 ignored. - Invariance: `eslint.config.js` sets no `parserOptions.project` / `projectService`, so type-aware linting is off, and no local rule reads another file. So this diff cannot move a verdict on an untouched file. - `ObjectGantt.tsx` warnings went from 84 at base to 81 at head: `no-explicit-any` 75 to 71, and `react-hooks/refs` 2 to 3 (the render-time ref write, the same pattern as `effectiveDataSourceRef` and `reloadRef`). - Repo-wide lint, the full test shards and the other `check:*` families are left to CI. ## Acceptance notes (not filed) - **Measured behaviour change in an edge case with no caller.** A direct caller that spreads `data: []` into a gantt with no record source and no `dataSource` now sees the chart's own error, "DataSource required for object/api providers", where base drew an empty chart. I measured this with a throwaway probe against both blobs and deleted the probe afterwards. It follows directly from the ruled semantics: the chart reads its own source, and here it has none. Once the host's rows arrive, the host branch adopts them and clears the error, as the adapter branch does. That last sentence is read from the code; I did not measure it for this no-source case. - **Unchanged and still untracked:** a host swapping one NON-EMPTY array for another does not re-run the chart's load. The fetch effect keys on whether there are host rows, not on which rows they are. That was already the case before this change, and no caller exists. Carrier: none. - `ListView.tsx`'s `ganttOwnsData` block still calls objectui#7210 half 2 "an open maintainer decision", and the `surfaceDrawsFetchedRows` block still says the gantt query "carries no `$top` at all". Both have been stale since PR #7391. I left them alone because they are outside this card. Carrier: none. Session: `https://claude.ai/code/session_01MCg3z5cGrV51xEddpGcxEY` (PM seat `domain:ui#4`, dispatched os-dev run). --- _Generated by [Claude Code](https://claude.ai/code/session_01MCg3z5cGrV51xEddpGcxEY)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 97672ba commit 67d4ed9

5 files changed

Lines changed: 297 additions & 20 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@object-ui/plugin-gantt': patch
3+
---
4+
5+
`ObjectGantt` no longer treats an EMPTY host `data` array as the rows it was handed (objectui#7333).
6+
7+
`ObjectGantt` read a host `data` prop at two places, and both accepted `[]`. The
8+
reload's short-circuit tested `data && Array.isArray(data)`, and an empty array
9+
is truthy, so the chart adopted it and returned before its own query. The gating
10+
flag tested `Array.isArray(data)` alone, so the same array also switched off the
11+
object-schema gate and the data-invalidation subscription of that query. A gantt
12+
whose `data` names its own source, for example `{ provider: 'api', read }`,
13+
therefore painted an EMPTY chart whenever a host handed it an array it had not
14+
filled yet.
15+
16+
Both places now read one predicate. A host `data` array is adopted only when it
17+
has rows. An empty one reads as "no host rows yet": the chart queries its own
18+
source, exactly as it does with no host array at all, and adopts the host's rows
19+
when they arrive.
20+
21+
Who can reach this: the registered `object-gantt` renderer still forwards no
22+
host prop, and `ObjectGanttProps` does not declare `data`, so only a caller that
23+
renders `ObjectGantt` directly and spreads `data` in was affected.
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
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+
* objectui#7333 — an EMPTY host `data` array is "no host rows yet", not "the
11+
* host owns zero rows".
12+
*
13+
* `ObjectGantt` read a host `data` prop at two sites, and both took `[]` as an
14+
* authoritative answer: `reload`'s short-circuit (`data && Array.isArray(data)`
15+
* — `[]` is truthy) adopted it and returned before the chart's own query, and
16+
* the gating flag (`Array.isArray(data)`) switched off the object-schema gate
17+
* and the invalidation subscription that belong to that query. So a gantt whose
18+
* `data` names its own source painted an EMPTY chart the moment a host handed
19+
* it an array it had not filled yet.
20+
*
21+
* Both sites now read one predicate, `hostRows` in `ObjectGantt.tsx`: a
22+
* non-empty host array is adopted as it always was, and an empty one leaves the
23+
* chart reading from its own source, exactly as with no host array at all.
24+
*
25+
* ⚠️ Reach: the registered `object-gantt` renderer forwards no host prop, which
26+
* `ObjectGantt.hostDataProp-7210.test.tsx` pins, and `ObjectGanttProps` does
27+
* not declare `data`. So every case here renders `ObjectGantt` directly and
28+
* spreads the prop in, as a direct caller would have to.
29+
*
30+
* Cases 1 and 4 are the pins; 2 and 3 are their controls, and 5 is the "yet":
31+
* 1. api provider + host `[]` ⇒ the endpoint is read and its rows paint;
32+
* 2. api provider + host rows ⇒ those rows paint, the endpoint is never read;
33+
* 3. api provider + no host `data` ⇒ the endpoint is read;
34+
* 4. object provider + host `[]` ⇒ the query waits for the object schema and
35+
* goes out ONCE, already expanded (the gating flag's half);
36+
* 5. host rows that arrive after an empty first render are adopted.
37+
*/
38+
39+
import React from 'react';
40+
import { render, screen, waitFor, act } from '@testing-library/react';
41+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
42+
import { SchemaRendererProvider } from '@object-ui/react';
43+
import { ObjectGantt } from './ObjectGantt';
44+
45+
vi.mock('sonner', () => ({ toast: { error: vi.fn() } }));
46+
47+
vi.mock('./GanttView', () => ({
48+
GanttView: ({ tasks }: any) => (
49+
<div data-testid="gantt-view" data-task-count={String(tasks.length)}>
50+
{tasks.map((t: any) => (
51+
<div key={t.id} data-testid={`gv-task-${t.id}`}>{t.title}</div>
52+
))}
53+
</div>
54+
),
55+
}));
56+
57+
vi.mock('@object-ui/plugin-detail', async (importOriginal) => ({
58+
...(await importOriginal<typeof import('@object-ui/plugin-detail')>()),
59+
RecordDetailDrawer: () => null,
60+
deriveRecordPageHref: () => null,
61+
}));
62+
63+
/** What the gantt's own `api` endpoint answers with. */
64+
const ENDPOINT_ROWS = [
65+
{ id: 'e1', name: 'Endpoint task 1', start_date: '2026-01-01', end_date: '2026-01-05' },
66+
{ id: 'e2', name: 'Endpoint task 2', start_date: '2026-01-02', end_date: '2026-01-06' },
67+
];
68+
69+
/** What a host hands down as `data` when it DOES have rows. */
70+
const HOST_ROWS = [
71+
{ id: 'h1', name: 'Host task 1', start_date: '2026-02-01', end_date: '2026-02-03' },
72+
];
73+
74+
const ENDPOINT = '/api/gantt/tree';
75+
76+
function apiSchema(): any {
77+
return {
78+
type: 'object-gantt',
79+
objectName: 'tasks',
80+
gantt: { titleField: 'name', startDateField: 'start_date', endDateField: 'end_date' },
81+
data: { provider: 'api', read: { url: ENDPOINT, method: 'GET' } },
82+
};
83+
}
84+
85+
function makeApiFetch() {
86+
return vi.fn(async () =>
87+
new Response(JSON.stringify({ data: ENDPOINT_ROWS, total: ENDPOINT_ROWS.length }), {
88+
status: 200,
89+
headers: { 'Content-Type': 'application/json' },
90+
}),
91+
);
92+
}
93+
94+
/** The URLs the endpoint was read at, in order. */
95+
function readUrls(apiFetch: ReturnType<typeof makeApiFetch>): string[] {
96+
return (apiFetch.mock.calls as unknown as Array<[unknown]>).map(([url]) => String(url));
97+
}
98+
99+
/** Renders an api-provider gantt, spreading `hostProps` in as a direct caller would. */
100+
function renderApiGantt(apiFetch: ReturnType<typeof makeApiFetch>, hostProps: Record<string, unknown>) {
101+
const tree = (props: Record<string, unknown>) => (
102+
<SchemaRendererProvider dataSource={null} apiFetch={apiFetch as any}>
103+
<ObjectGantt schema={apiSchema()} {...(props as any)} />
104+
</SchemaRendererProvider>
105+
);
106+
const utils = render(tree(hostProps));
107+
return { ...utils, rerenderWith: (props: Record<string, unknown>) => utils.rerender(tree(props)) };
108+
}
109+
110+
const taskCount = () => screen.getByTestId('gantt-view').getAttribute('data-task-count');
111+
112+
/** Lets every in-flight read settle, so a query that would follow is counted. */
113+
const settle = () => act(() => new Promise<void>((resolve) => setTimeout(resolve, 100)));
114+
115+
describe('objectui#7333 — an api-provider gantt handed an EMPTY host array still reads its endpoint', () => {
116+
// No test here may reach the network through the bare global fetch.
117+
const bareFetch = vi.fn(async () => new Response('{}', { status: 599 }));
118+
119+
beforeEach(() => {
120+
bareFetch.mockClear();
121+
vi.stubGlobal('fetch', bareFetch);
122+
});
123+
124+
afterEach(() => {
125+
vi.unstubAllGlobals();
126+
});
127+
128+
it('host `data: []` ⇒ the endpoint is read and its rows paint', async () => {
129+
const apiFetch = makeApiFetch();
130+
131+
renderApiGantt(apiFetch, { data: [] });
132+
133+
await waitFor(() => expect(screen.getByTestId('gv-task-e2')).toBeTruthy());
134+
expect(taskCount()).toBe(String(ENDPOINT_ROWS.length));
135+
expect(readUrls(apiFetch).some((url) => url.includes(ENDPOINT))).toBe(true);
136+
expect(bareFetch).not.toHaveBeenCalled();
137+
});
138+
139+
it('CONTROL — host `data` with rows ⇒ those rows paint and the endpoint is never read', async () => {
140+
const apiFetch = makeApiFetch();
141+
142+
renderApiGantt(apiFetch, { data: HOST_ROWS });
143+
144+
await waitFor(() => expect(screen.getByTestId('gv-task-h1')).toBeTruthy());
145+
expect(taskCount()).toBe(String(HOST_ROWS.length));
146+
expect(screen.queryByTestId('gv-task-e1')).toBeNull();
147+
expect(apiFetch).not.toHaveBeenCalled();
148+
});
149+
150+
it('CONTROL — no host `data` ⇒ the endpoint is read', async () => {
151+
const apiFetch = makeApiFetch();
152+
153+
renderApiGantt(apiFetch, {});
154+
155+
await waitFor(() => expect(screen.getByTestId('gv-task-e2')).toBeTruthy());
156+
expect(readUrls(apiFetch).some((url) => url.includes(ENDPOINT))).toBe(true);
157+
});
158+
159+
it('host rows that arrive after an empty first render are adopted', async () => {
160+
const apiFetch = makeApiFetch();
161+
162+
const { rerenderWith } = renderApiGantt(apiFetch, { data: [] });
163+
await waitFor(() => expect(screen.getByTestId('gv-task-e2')).toBeTruthy());
164+
165+
rerenderWith({ data: HOST_ROWS });
166+
167+
await waitFor(() => expect(screen.getByTestId('gv-task-h1')).toBeTruthy());
168+
expect(taskCount()).toBe(String(HOST_ROWS.length));
169+
expect(screen.queryByTestId('gv-task-e1')).toBeNull();
170+
});
171+
});
172+
173+
describe('objectui#7333 — an EMPTY host array does not switch off the object-schema gate', () => {
174+
/** A definition with a lookup, so the gated query has a real `$expand` to carry. */
175+
const OBJECT_DEF = {
176+
name: 'task',
177+
fields: {
178+
id: { name: 'id', type: 'text' },
179+
subject: { name: 'subject', type: 'text' },
180+
owner: { name: 'owner', type: 'lookup', reference_to: 'user' },
181+
visible_from: { name: 'visible_from', type: 'date' },
182+
due_date: { name: 'due_date', type: 'date' },
183+
},
184+
};
185+
186+
const OBJECT_ROWS = [
187+
{ id: '1', subject: 'Renewal', owner: 'u1', visible_from: '2026-01-01', due_date: '2026-01-05' },
188+
];
189+
190+
const objectSchema: any = {
191+
type: 'object-gantt',
192+
objectName: 'task',
193+
gantt: { titleField: 'subject', startDateField: 'visible_from', endDateField: 'due_date' },
194+
};
195+
196+
it('host `data: []` on an object-bound gantt ⇒ ONE query, issued after the schema settles, already expanded', async () => {
197+
const adapter = {
198+
find: vi.fn(async () => ({ data: OBJECT_ROWS, total: OBJECT_ROWS.length })),
199+
findOne: vi.fn(),
200+
create: vi.fn(),
201+
update: vi.fn(),
202+
delete: vi.fn(),
203+
getObjectSchema: vi.fn(async () => OBJECT_DEF),
204+
} as any;
205+
206+
render(<ObjectGantt schema={objectSchema} dataSource={adapter} {...({ data: [] } as any)} />);
207+
208+
await waitFor(() => expect(taskCount()).toBe(String(OBJECT_ROWS.length)));
209+
await waitFor(() => expect(adapter.find).toHaveBeenCalled());
210+
await settle();
211+
// Ungated, the first query goes out before the definition lands and
212+
// carries no expansion, and a second follows once it does: `[null,
213+
// ['owner']]` — the signature `ObjectGantt.fetchGate-7225.test.tsx`
214+
// records for the ungated regime.
215+
const expandSets = adapter.find.mock.calls.map(([, params]: [string, any]) => params?.$expand ?? null);
216+
expect(expandSets).toEqual([['owner']]);
217+
});
218+
});

‎packages/plugin-gantt/src/ObjectGantt.tsx‎

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,37 @@ export const ObjectGantt: React.FC<ObjectGanttProps> = ({
840840
* over by hand.
841841
*/
842842
const reportOwedRef = useRef(false);
843+
/**
844+
* Rows a HOST component handed down as a `data` prop, or `null` when it
845+
* handed none (objectui#7333).
846+
*
847+
* ⭐ An EMPTY array is `null` here. It is "no host rows yet", ⛔ not "the
848+
* host owns zero rows". Both sites that read this prop — the short-circuit
849+
* at the head of `reload` and `recordQueryDerivesExpand` below — used to
850+
* take `[]` as an authoritative answer (`[]` is truthy, and
851+
* `Array.isArray([])` holds): the chart adopted it and returned before its
852+
* own query, and painted an EMPTY chart in place of the rows its `data`
853+
* config names. A host array that has not been filled yet looks exactly like
854+
* that. So an empty array leaves the chart reading from its own source, as it
855+
* does with no host array at all; a NON-EMPTY one is adopted as it always
856+
* was. Pinned in `ObjectGantt.emptyHostData-7333.test.tsx`.
857+
*
858+
* One predicate, evaluated once per render, for BOTH sites. `reload` reads it
859+
* through `hostRowsRef` rather than closing over `rest`: `reload` does not
860+
* key on the host rows, so a closed-over value is the one from whichever
861+
* render last rebuilt `reload`. When a host's rows arrive after an empty
862+
* first render, `recordQueryDerivesExpand` flips and fires the fetch effect,
863+
* and that run must see the rows that flipped it, not the `[]` before them.
864+
*
865+
* ⚠️ The registry path never hands this prop: the registered `object-gantt`
866+
* renderer forwards no host prop (`ObjectGantt.hostDataProp-7210.test.tsx`
867+
* pins that), and `ObjectGanttProps` does not declare `data`. What reaches it
868+
* is a direct caller that spreads one in.
869+
*/
870+
const hostRowsProp: unknown = (rest as Record<string, unknown>).data;
871+
const hostRows = Array.isArray(hostRowsProp) && hostRowsProp.length > 0 ? hostRowsProp : null;
872+
const hostRowsRef = useRef(hostRows);
873+
hostRowsRef.current = hostRows;
843874
const reload = useCallback(async ({ silent = false, inPlace = silent }: { silent?: boolean; inPlace?: boolean } = {}) => {
844875
const seq = ++reloadSeqRef.current;
845876
const isCurrent = () => reloadSeqRef.current === seq;
@@ -848,10 +879,12 @@ export const ObjectGantt: React.FC<ObjectGanttProps> = ({
848879
try {
849880
if (inPlace) setRefreshing(true);
850881
else setLoading(true);
851-
// 1. Check for data prop (Unified ListView)
852-
if ((rest as any).data && Array.isArray((rest as any).data)) {
882+
// 1. Rows a host handed down — non-empty only (objectui#7333); see
883+
// `hostRows` above for why this reads the ref.
884+
const handedRows = hostRowsRef.current;
885+
if (handedRows) {
853886
if (isCurrent()) {
854-
setData((rest as any).data);
887+
setData(handedRows);
855888
setRowCeiling(null);
856889
// Committed rows clear an earlier failure (objectui#10578) — the
857890
// reasoning sits on the adapter's commit below.
@@ -1003,18 +1036,21 @@ export const ObjectGantt: React.FC<ObjectGanttProps> = ({
10031036
// The fetch effect below repeats this list for the same reason; the pins in
10041037
// `ObjectGantt.discardedReloadIdentity-10036.test.tsx` hold the two in
10051038
// parity by exercising each entry.
1006-
// eslint-disable-next-line react-hooks/exhaustive-deps -- (rest as any).data intentionally untracked, matching the original effect
1039+
// eslint-disable-next-line react-hooks/exhaustive-deps -- `searchFields` is keyed by its serialised value, `searchFieldsKey`; the host rows are read through `hostRowsRef` (objectui#7333)
10071040
}, [adapterInputsKey, dataSource, apiFetch, resource, hasInlineData, dataProvider, queryFilter, schema.sort, searchTerm, searchFieldsKey, objectSchema, perms]);
10081041

10091042
/**
10101043
* Does the query this effect is about to issue DERIVE anything from the
1011-
* object schema? Only the adapter branch does. A host-supplied `data` array
1012-
* and an inline `value` set both paint with no metadata read at all, so
1013-
* gating them would hold a paint on a resolution that buys them nothing.
1014-
* Same scoping ObjectCalendar's gate uses, and for the same reason.
1044+
* object schema? Only the adapter branch does. Rows a host handed down and
1045+
* an inline `value` set both paint with no metadata read at all, so gating
1046+
* them would hold a paint on a resolution that buys them nothing. Same
1047+
* scoping ObjectCalendar's gate uses, and for the same reason.
1048+
*
1049+
* "Rows a host handed down" is `hostRows`, the predicate `reload` reads — an
1050+
* EMPTY host array is not one (objectui#7333), so it keeps the gate and the
1051+
* invalidation subscription of the query the chart still issues.
10151052
*/
1016-
const hasHostData = Array.isArray((rest as any).data);
1017-
const recordQueryDerivesExpand = !hasHostData && !hasInlineData;
1053+
const recordQueryDerivesExpand = hostRows === null && !hasInlineData;
10181054

10191055
// ⭐ objectui#7225 ask 2 (objectui#6482's undischarged gating half) — the
10201056
// object schema GATES this query; it does not refine it afterwards.

‎packages/plugin-list/src/ListView.tsx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,12 +2071,12 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
20712071
// The withholding is kept anyway: it is unreachable, not wrong, and it stops
20722072
// being unreachable the moment that wrapper forwards host props — whether a
20732073
// non-grid view may fetch unbounded at all is an open maintainer decision
2074-
// (objectui#7210, half 2). `ObjectGantt.reload` takes its `rest.data`
2075-
// short-circuit on `data && Array.isArray(data)`, and `[]` satisfies both,
2076-
// while this view's rows array is never filled (the fetch effect below
2077-
// returns early for it). Forwarding it would therefore replace the endpoint's
2078-
// tree with an EMPTY chart — not with the stale object rows the old comment
2079-
// warned about.
2074+
// (objectui#7210, half 2). This view's rows array is not the endpoint's
2075+
// answer (the fetch effect below returns early for it), and `ObjectGantt`
2076+
// adopts any NON-EMPTY host `data` array as its rows. An EMPTY one no longer
2077+
// blanks the chart: it reads as "no host rows yet" and the chart still
2078+
// queries its endpoint (objectui#7333). So the withholding guards against
2079+
// this array ever being adopted in the endpoint's place.
20802080
const ganttOwnsData =
20812081
currentView === 'gantt' &&
20822082
!!schema.data &&

‎packages/plugin-list/src/__tests__/ListView.test.tsx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,10 +2686,10 @@ describe('ListView — gantt view fed by an api-provider ViewData', () => {
26862686
// `plugin-gantt/src/ObjectGantt.hostDataProp-7210.test.tsx`). That makes (c)
26872687
// a guard on a path the registry does not currently reach — keep it. The day
26882688
// that wrapper forwards host props (objectui#7210, half 2, an open maintainer
2689-
// decision) it becomes load-bearing: `ObjectGantt.reload` short-circuits on
2690-
// `data && Array.isArray(data)`, and this view's rows array is a truthy `[]`
2691-
// forever, so handing it down would paint an EMPTY chart in place of the
2692-
// endpoint's tree.
2689+
// decision) it becomes load-bearing: this view's rows array is not the
2690+
// endpoint's answer, and `ObjectGantt` adopts any NON-EMPTY host array as its
2691+
// rows. (An EMPTY one no longer blanks the chart: it reads as "no host rows
2692+
// yet" and the chart still queries its endpoint, objectui#7333.)
26932693
let prevObjectGantt: ReturnType<typeof ComponentRegistry.get>;
26942694
let ganttCalls: any[];
26952695

0 commit comments

Comments
 (0)