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

Commit 6d1e77c

Browse files
fix(plugin-list): a held user filter does not narrow the fetch on a dataset-bound chart (objectui#10512) (#10597)
Fixes #10512 Clause-②: no ## What changes objectui#10327 withholds the toolbar Filter builder and the `UserFilters` chips while a dataset-bound `chart` is on screen (`datasetChartOnScreen`), but only the controls. A group the host restored at mount (`initialFilters`), or one set on a grid before an in-list switch, still reached `ListView`'s own fetch, and so the record-count bar. This PR withholds the APPLIED user filter too, in the shape objectui#10326 gave Search (`searchTerm` derived empty beside the held `searchInput`), as the triage ruled (comment 5829668693). - `appliedFilters` / `appliedUserFilterConditions` are derived beside the held `currentFilters` / `userFilterConditions`: empty while `datasetChartOnScreen`, the held value otherwise. - The held state is not touched: a switch back to a view that offers the controls applies it again, and `onFilterChange` is not called for the switch. - The view's own `schema.filter` is not the user's filter and stays in the query. - Each held source is swapped for a module constant only when it holds something, so a switch into the dataset chart with nothing held hands the fetch effect the identities it already had and re-issues no query (the objectui#7394 class). - ⛔ The toolbar gate (`showFilters` / `showUserFilters`) from objectui#10327 is unchanged: no diff line touches either flag. ### Readers of the user filter Switched to the applied value: - the fetch: `buildEffectiveFilter` in the fetch effect, and the effect's dependency list; - the server export: `buildEffectiveFilter` in the export callback, and its dependency list (the client export writes `data`, the fetch's own answer); - `pageResetSignature`; - `selfQueryFilter`, with no behaviour change: its consumers (the gantt, tree and object-bound chart nodes) are views on which `datasetChartOnScreen` is false, so applied equals held there, and the dataset node carries no filter (objectui#10327). Switched so that its comment, "the SAME effective filter this component's own fetch sends", stays literally true; - the grid empty-state `hasActiveQuery`, with no behaviour change (grid only, where applied equals held). Left on the held state, deliberately: - the Filter builder's `value`, and its trigger's `hasFilters` highlight and badge count: the control that shows and edits the held group, not rendered on the dataset chart; - `UserFilters`, which keeps its own selection state and is not rendered on the dataset chart; - the host write-back (`onFilterChange`, `onUserFilterSelectionsChange`), fired only by the controls, so the host's storage keeps the held state. ## H0, measured first (objectui `origin/main` `a506001`) A component-level probe (not committed): the real `ListView`, an `object-chart` stand-in that records the node it is handed, a dataset-bound `chart` block, and `initialFilters` restoring `status equals open` over three rows. Readings on the base: - the chart node was the dataset shape (`dataset: task_ds`, no `filter` key); - `ListView`'s fetch ran, 1 call, with `$filter` = `["status","=","open"]`; - the record-count bar rendered and read `1 record` (3 rows unnarrowed); - neither the Filter builder nor the chips were on screen. The fetch runs AND the count bar draws, so the narrowing is user-visible and the fix lands. ⛔ Not rendered in a browser: the count bar is `ListView`'s own DOM, independent of the chart renderer. ## Pins `ListView.datasetChartAppliedFilter-10512.test.tsx` in `packages/plugin-list/src/__tests__`, 6 cases. Each asserts the query the data source receives (the fake answers from the fields its `$filter` names, so the count bar reads a different number for a narrowed query): 1. CONTROL: on a grid, a restored group narrows the fetch, and the count bar reads `1 record`. 2. CONTROL: on a chart bound to the list object, a restored group still narrows the fetch. 3. On a dataset-bound chart the fetch runs and the count bar draws, and a restored group narrows neither: no `$filter` in any call, the bar reads `3 records`, `onFilterChange` not called. 4. The view's own `filter` stays in the query on the dataset chart, alone: every call's `$filter` equals the base filter, the bar reads `2 records`. 5. A group restored on a grid plus a chip toggled there stop narrowing the fetch on a switch to the dataset chart, and the group applies again back on the grid; the builder badge still reads 1 and `onFilterChange` is never called. 6. CONTROL (objectui#7394): with nothing held, the switch to the dataset chart re-issues no query. ### Reverse verification (from the committed fix) `ListView.tsx` checked out at the base `a506001` (on-disk blob `03798ad` equal to the base blob; 0 occurrences of `appliedFilters` on disk), the pin run, then restored with `git checkout HEAD --` under a trap (restored blob `d86a5db` equal to the HEAD blob, `git diff HEAD` 0 bytes): - base leg: exit 1, `Tests 3 failed | 3 passed (6)`; red are cases 3, 4 and 5, green are the three controls; - fix leg: exit 0, `Tests 6 passed (6)`. ### Ablation (the objectui#7394 control can fail) Predicted before running: an unconditional swap of the Filter group turns case 6 red and nothing else. Run through `ablation-replace.mjs` (anchor `datasetChartOnScreen && currentFilters.conditions && currentFilters.conditions.length > 0`, 1 hit, anchor count 1 to 0, blob `d86a5db` to `d364171`): exit 1, `Tests 1 failed | 5 passed (6)`, the failed case is case 6. Restored: blob equal to HEAD, `git diff HEAD` empty. Observed direction matches the prediction. ## Verification (final head `ad119b4`, after merging `origin/main` `f5178a2`) - `pnpm exec vitest run packages/plugin-list/ --maxWorkers=2`: exit 0, `Test Files 94 passed (94)`, `Tests 1131 passed (1131)`. - `pnpm turbo run type-check --filter @object-ui/plugin-list --concurrency=2`: exit 0, `Tasks: 14 successful, 14 total`, plugin-list a cache miss; `tsconfig.test.json` lists the new pin (`--listFilesOnly`, 1 hit). - `pnpm exec eslint` on `ListView.tsx` and the new pin: exit 0, 0 errors; per-rule warning counts on `ListView.tsx` equal to the base file's (compared in one `--format json` run). - `pnpm check:control-bytes`, `check:test-path-roots`, `check:vi-mock-specifiers`, `check:vi-mock-inherit`, `check:vi-mock-override-shape`, `check:new-line-citations` (0 new citations), `check:changeset-claims`, `check:pending-changeset-literals`, `check:shell-escape-residue`, `check:handler-key-reads`, `check:i18n-keys`, `check:unreferenced-sources`: each exit 0. - `node scripts/check-changeset-presence.mjs`, `check-changeset-no-major.mjs`, `check-type-check-coverage.mjs`, `check-lint-coverage.mjs`: each exit 0. - ⛔ The repo-wide `pnpm lint` and the full `pnpm test` are CI's. `check:changeset-claims` names 7 pending changesets that mention `ListView.tsx` (`7070-no-invented-gantt-date-fields`, `7499-gantt-non-axis-floors-omitted`, `7773-kanban-adapter-groupfield-write`, `7780-object-kanban-record-source`, `8990-object-kanban-groupby-optional`, `list-user-actions-collision-5398`, `listview-comment-pair-4559`). Each paragraph was read; none is about how the user filter is applied, and none is made false by this diff. ## Changeset `.changeset/10512-dataset-chart-applied-filter.md`, `patch` for `@object-ui/plugin-list`. ## Acceptance notes - **Chip state across an in-list switch (pre-existing, not changed here).** Measured on the base `a506001` with the same probe harness: toggle a `UserFilters` chip ON on a grid, switch to the dataset chart, switch back. The chip renders OFF again (its button carries the outline variant), while `ListView`'s held `userFilterConditions` still sends `["priority","!=",null]` and the count bar reads `2 records`. `UserFilters` keeps its selection in its own state, and the objectui#10327 gate unmounts it on the dataset chart. This PR leaves the grid leg exactly as it was (applied equals held there); the pin deliberately does not assert the chip's return. Reported to the seat as a separate finding. Dropdown and tab chips were not measured. - **An unfinished builder row.** The swap keys on the held group's row count, not on its compiled filter (compiling at render could throw a `FilterOperatorError`). A held group whose every row is unfinished therefore still swaps on a switch into the dataset chart, and that one switch re-issues a query equal to the one before it. The session that implemented this: `https://claude.ai/code/session_01KUxVUa7e39aNjhkKi1gsoy` (domain:ui seat 5 dispatch). --- _Generated by [Claude Code](https://claude.ai/code/session_01KUxVUa7e39aNjhkKi1gsoy)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent d3df3c0 commit 6d1e77c

3 files changed

Lines changed: 309 additions & 8 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
'@object-ui/plugin-list': patch
3+
---
4+
5+
On a `chart` list view bound to a semantic `dataset`, a user filter that is already set
6+
no longer narrows `ListView`'s own fetch (objectui#10512).
7+
8+
The toolbar withholds the Filter builder and the `userFilters` chips on such a view
9+
(objectui#10327), but a filter group the host restored at mount through
10+
`initialFilters`, or a group or chip set on another view before switching, was still
11+
applied to `ListView`'s own fetch of the object's rows. That fetch still runs on the
12+
chart and feeds the record-count bar, so the count was narrowed by a filter nothing on
13+
screen showed or could clear.
14+
15+
- While a dataset-bound chart is on screen, `ListView`'s fetch and its export apply
16+
the view's own `filter` only; the toolbar's filter group and the chips are not sent.
17+
- The held state is kept rather than cleared: switching back to a view that offers the
18+
controls applies the same group again, and `onFilterChange` is not called for the
19+
switch.
20+
- A chart bound to the list object, and every other view, apply the toolbar's filter
21+
group and the chips as before. A switch into a dataset chart with no user filter set
22+
issues no new request.

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

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,14 @@ export function buildEffectiveFilter(
683683
);
684684
}
685685

686+
/**
687+
* What `ListView` applies in place of a held user filter it withholds
688+
* (`appliedFilters` / `appliedUserFilterConditions`, objectui#10512). Module
689+
* constants, so every render hands the fetch effect the same identity.
690+
*/
691+
const WITHHELD_FILTER_GROUP: FilterGroup = { id: 'root', logic: 'and', conditions: [] };
692+
const WITHHELD_USER_FILTER_CONDITIONS: unknown[] = [];
693+
686694
export function convertFilterGroupToAST(group: FilterGroup): any[] {
687695
if (!group || !group.conditions || group.conditions.length === 0) return [];
688696

@@ -1145,6 +1153,15 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
11451153
* a dataset chart — is refused at authoring by `@object-ui/types`'
11461154
* `ListViewSchema`.
11471155
*
1156+
* Two readers, one answer: the toolbar flags below, and the APPLIED user
1157+
* filter (`appliedFilters` / `appliedUserFilterConditions`, objectui#10512).
1158+
* A group the host restores at mount, or one set on a grid before a switch,
1159+
* therefore does not go on narrowing this component's fetch — and with it the
1160+
* record-count bar — with no control on screen to show or clear it. ⛔ The
1161+
* held state itself is kept: switching back to a view that offers the
1162+
* controls applies it again. The view's own `schema.filter` is not the
1163+
* user's filter and stays applied.
1164+
*
11481165
* Asked of `resolveListChartBinding`, the SAME resolver `case 'chart'` routes
11491166
* on, so the toolbar and the render branch cannot disagree about the shape.
11501167
* A primitive, so the memo below keys on the answer, not on an identity
@@ -1488,6 +1505,22 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
14881505
// User Filters State (Airtable Interfaces-style)
14891506
const [userFilterConditions, setUserFilterConditions] = React.useState<any[]>([]);
14901507

1508+
// The user filter this component APPLIES — its fetch, the export, the node of
1509+
// a view that queries for itself, the empty-state copy. Empty while a
1510+
// dataset-bound chart is on screen (`datasetChartOnScreen`, objectui#10512).
1511+
// The held `currentFilters` / `userFilterConditions` stay as they are, for
1512+
// the controls and for the host's storage. Each is swapped only when it holds
1513+
// something, so a switch with nothing held hands the fetch effect the
1514+
// identities it already had and re-issues no query (objectui#7394).
1515+
const appliedFilters =
1516+
datasetChartOnScreen && currentFilters.conditions && currentFilters.conditions.length > 0
1517+
? WITHHELD_FILTER_GROUP
1518+
: currentFilters;
1519+
const appliedUserFilterConditions =
1520+
datasetChartOnScreen && userFilterConditions.length > 0
1521+
? WITHHELD_USER_FILTER_CONDITIONS
1522+
: userFilterConditions;
1523+
14911524
// User filters render ONLY when explicitly configured (ADR-0047 §data
14921525
// mode): saved list views already act as the preset switcher, so an
14931526
// unconfigured view keeps a clean toolbar instead of growing auto-derived
@@ -2154,7 +2187,7 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
21542187
try {
21552188
// Construct filter — shared with the export path so the file a user
21562189
// downloads is built from the same three sources as the rows on screen.
2157-
const finalFilter = buildEffectiveFilter(schema.filter, currentFilters, userFilterConditions);
2190+
const finalFilter = buildEffectiveFilter(schema.filter, appliedFilters, appliedUserFilterConditions);
21582191

21592192
// Convert sort to query format
21602193
// Use array format to ensure order is preserved (Object keys are not guaranteed ordered)
@@ -2663,7 +2696,7 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
26632696
// silently un-suppresses nothing, because the finding it was suppressing
26642697
// simply moves elsewhere. Add prose ABOVE this point, never below it.
26652698
// eslint-disable-next-line react-hooks/exhaustive-deps
2666-
}, [schema.objectName, schema.data, dataSource, schema.filter, effectivePageSize, currentSort, currentFilters, userFilterConditions, refreshKey, searchTerm, schema.searchableFields, schema.columns, (schema as any).kanban, (schema as any).calendar, (schema as any).gallery, (schema as any).timeline, (schema as any).gantt, schema.map, (schema as any).options, objectDef?.fields, objectDefLoaded, schema.refreshTrigger, perms, fetchSkip, groupingConfig, ganttOwnsData]); // Re-fetch on filter/sort/search/refreshTrigger/perms/window change
2699+
}, [schema.objectName, schema.data, dataSource, schema.filter, effectivePageSize, currentSort, appliedFilters, appliedUserFilterConditions, refreshKey, searchTerm, schema.searchableFields, schema.columns, (schema as any).kanban, (schema as any).calendar, (schema as any).gallery, (schema as any).timeline, (schema as any).gantt, schema.map, (schema as any).options, objectDef?.fields, objectDefLoaded, schema.refreshTrigger, perms, fetchSkip, groupingConfig, ganttOwnsData]); // Re-fetch on filter/sort/search/refreshTrigger/perms/window change
26672700

26682701
// Any change to the result-defining inputs (object, filters, sort, search,
26692702
// grouping, page size) invalidates the current page number — snap back to
@@ -2674,7 +2707,7 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
26742707
// the signature, so turning the page never triggers a reset.
26752708
const pageResetSignature = JSON.stringify([
26762709
schema.objectName, schema.filter, effectivePageSize, currentSort,
2677-
currentFilters, userFilterConditions, searchTerm, currentView, groupingConfig,
2710+
appliedFilters, appliedUserFilterConditions, searchTerm, currentView, groupingConfig,
26782711
]);
26792712
const prevPageResetSignature = React.useRef(pageResetSignature);
26802713
React.useEffect(() => {
@@ -3042,7 +3075,7 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
30423075
let selfQueryFilter: unknown = schema.filter;
30433076
if (currentView === 'gantt' || currentView === 'tree' || currentView === 'chart') {
30443077
try {
3045-
const value = buildEffectiveFilter(schema.filter, currentFilters, userFilterConditions);
3078+
const value = buildEffectiveFilter(schema.filter, appliedFilters, appliedUserFilterConditions);
30463079
const key = JSON.stringify(value ?? null);
30473080
const cached = selfQueryFilterRef.current;
30483081
if (cached && cached.key === key) {
@@ -3964,7 +3997,7 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
39643997
.filter(Boolean) as string[];
39653998

39663999
// The same three filter sources as the data fetch, from the same function.
3967-
const finalFilter = buildEffectiveFilter(schema.filter, currentFilters, userFilterConditions);
4000+
const finalFilter = buildEffectiveFilter(schema.filter, appliedFilters, appliedUserFilterConditions);
39684001

39694002
const sort = currentSort.length > 0
39704003
? currentSort
@@ -4066,7 +4099,7 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
40664099
setShowExport(false);
40674100
// `searchTerm` / `searchableFields` belong here: the export now narrows by
40684101
// the active search, so a stale closure would export the wrong row set.
4069-
}, [data, effectiveFields, resolvedExportOptions, schema.objectName, schema.filter, schema.searchableFields, exportPermitted, dataSource, currentFilters, userFilterConditions, currentSort, searchTerm, objectDef, resolveObjectLabel]);
4102+
}, [data, effectiveFields, resolvedExportOptions, schema.objectName, schema.filter, schema.searchableFields, exportPermitted, dataSource, appliedFilters, appliedUserFilterConditions, currentSort, searchTerm, objectDef, resolveObjectLabel]);
40704103

40714104
// All available fields for hide/show (with i18n)
40724105
const allFields = React.useMemo(() => {
@@ -4933,8 +4966,8 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
49334966
const hasActiveQuery =
49344967
!!(searchTerm && searchTerm.trim()) ||
49354968
hasBaseFilter ||
4936-
(Array.isArray(userFilterConditions) && userFilterConditions.length > 0) ||
4937-
(Array.isArray(currentFilters?.conditions) && currentFilters.conditions.length > 0);
4969+
(Array.isArray(appliedUserFilterConditions) && appliedUserFilterConditions.length > 0) ||
4970+
(Array.isArray(appliedFilters?.conditions) && appliedFilters.conditions.length > 0);
49384971
const title = (typeof schema.emptyState?.title === 'string' ? schema.emptyState.title : undefined)
49394972
?? (hasActiveQuery ? t('list.noMatches') : t('list.firstRunTitle'));
49404973
const description = (typeof schema.emptyState?.message === 'string' ? schema.emptyState.message : undefined)

0 commit comments

Comments
 (0)