From 3117ebc275252bb356da6ccadc57c3e02047da61 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 22:38:17 +0000 Subject: [PATCH 1/2] feat(app-shell): the /data page keeps its list's search, sort, grouping and Filter panel in the address Claude-Session: https://claude.ai/code/session_01ADHkmRGDrq6JSytBsNFabU Co-authored-by: Claude --- .../app-shell/src/views/ObjectDataPage.tsx | 161 +++++++++++++++++- 1 file changed, 154 insertions(+), 7 deletions(-) diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.tsx index b7c74b61cd0..82cfea59011 100644 --- a/ui/packages/app-shell/src/views/ObjectDataPage.tsx +++ b/ui/packages/app-shell/src/views/ObjectDataPage.tsx @@ -1,8 +1,9 @@ /** * Object Data Page — the parameterized bare data surface (ADR-0055, #2251). * - * Route: `/apps/:appName/:objectName/data` (± `filter[]=` and - * `uf_` search params). + * Route: `/apps/:appName/:objectName/data` (± `filter[]=`, + * `uf_` and the list-state `uf__search` / `uf__sort` / `uf__group` / + * `uf__filter` search params). * * Where ObjectView anchors to a saved list view (default or `/view/:viewId`), * this surface is deliberately UNANCHORED — "the URL is the view": @@ -15,6 +16,10 @@ * • no saved-view tab bar — switching to a saved view is an explicit * navigation to `/view/:viewId` ("Save as view" is the exit); * • nothing here writes back to any saved view; + * • the list's own state — its search, sort, grouping and Filter panel — + * lives in the address too (objectstack#36408), under the keys ObjectView + * uses, so opening a record and closing it, or a reload, returns the list + * as the reader left it (see `listSeedRef`); * • the visualization switcher (grid/kanban/...) is ListView-internal, so * switching presentation never touches the URL — filter state survives; * • the common filter bar (ADR-0047 `userFilters` + `uf_*` persistence) is @@ -52,7 +57,16 @@ import { useAuth, useWorkspaceAdminStatus } from '@object-ui/auth'; import { resolveAffordance, resolveFilterPlaceholders, type SchemaLike } from '@object-ui/core'; import { normalizeFilterOperator, ViewFilterRuleSchema } from '@objectstack/spec/ui'; import type { ViewFilterRule } from '@objectstack/spec/ui'; -import { parseUserFilterParams, applyUserFilterParams } from './userFilterUrlState.js'; +import { + parseUserFilterParams, + applyUserFilterParams, + parseListStateParams, + applyListStateParams, + LIST_FILTER_PARAM, + type ListStatePatch, + type ListUrlFieldGate, + type ListUrlState, +} from './userFilterUrlState.js'; import { parseUrlFilterTriples, groupFilterChips, @@ -274,6 +288,37 @@ export function buildSaveAsViewSpec( }); } +/** + * objectstack#36408 — this page's own list defaults, for `ListView`'s + * `viewDefaults`: no sort and no grouping (the page has no view to declare + * either), the hidden fields and row height its `schema` never sets. The + * sort and grouping `schema` carries are the address's, so the list's + * 「Reset to default」 returns to these rather than to the address's. + */ +const DATA_PAGE_LIST_DEFAULTS = { hiddenFields: undefined, rowHeight: undefined, sort: undefined, grouping: undefined }; + +/** + * How many conditions the address's `uf__filter` carries, read from the + * envelope itself before any check: `0` for no param, or for a value that is + * not the `{ logic, conditions }` envelope at all (the address then carries no + * panel filter to refuse). The same count `ObjectView` judges a link's filter + * by (objectstack#31869), so a filter is refused whole on both lists. + */ +function addressPanelFilterConditionCount(searchParams: URLSearchParams): number { + const raw = searchParams.get(LIST_FILTER_PARAM); + if (!raw) return 0; + let parsed: unknown; + try { + parsed = JSON.parse(raw); + } catch { + return 0; + } + if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) return 0; + const { logic, conditions } = parsed as { logic?: unknown; conditions?: unknown }; + if (logic !== 'and' && logic !== 'or') return 0; + return Array.isArray(conditions) ? conditions.length : 0; +} + export function ObjectDataPage({ dataSource, objects }: any) { const { appName, objectName } = useParams(); const { t, language } = useObjectTranslation(); @@ -318,6 +363,84 @@ export function ObjectDataPage({ dataSource, objects }: any) { [setSearchParams], ); + /** + * objectstack#36408 — the list's own state in the address: the search term, + * the sort, the grouping and the Filter panel's conditions, under the keys + * `ObjectView` keeps them in (`uf__search`, `uf__sort`, `uf__group`, + * `uf__filter`; `userFilterUrlState` owns their names and shapes). Opening a + * record carries this address as the record page's origin, so its close — + * and a reload, and a copied link — open the list as the reader left it. + * + * Two layers, never one rewriting the other: `filter[...]` stays this page's + * own address conditions (the 「Filtered by」 tags, what 「Reset」 puts back + * to the source, what "Save as view" saves), and `uf__filter` is the Filter + * panel on top of them, exactly as `ObjectView` keeps the panel on top of its + * view's filter. The list applies both (the conditions AND the panel). + * + * The SEED — what the list opens with — is read from the address once per + * object and list generation (`ListView` takes its search and panel once, at + * mount). Unlike `ObjectView`, a reload is not a reset here: this page has + * no view to return to, and its address is the list ("the URL is the view"). + * Each piece passes `ObjectView`'s field gate: a field the object does not + * declare, or one this user cannot read once permissions are loaded, is + * dropped; a panel filter that loses any condition to the checks is refused + * whole, with `ObjectView`'s notice (objectstack#31869). The seed is then + * written back (replace), so the address shows what the list shows. + * + * 「Reset」 to the source (`resetToSource`) clears every `uf_` param, these + * included, and moves the generation: the list remounts on an empty seed, so + * it no longer searches, sorts, groups or filters by what the address lost. + */ + const [listGeneration, setListGeneration] = React.useState(0); + const listResetPendingRef = React.useRef(false); + const listSeedRef = React.useRef<{ key: string; state: ListUrlState; refusedPanelFilter?: boolean } | undefined>(undefined); + const listSeedKey = objectDef ? `${objectDef.name}~${listGeneration}` : undefined; + if (objectDef && listSeedKey && listSeedRef.current?.key !== listSeedKey) { + const reset = listResetPendingRef.current; + listResetPendingRef.current = false; + if (reset) { + listSeedRef.current = { key: listSeedKey, state: {} }; + } else { + const acceptField: ListUrlFieldGate = (field: string) => + !!objectDef.fields?.[field] + && (!perms.isLoaded || perms.checkField(objectDef.name, field, 'read')); + const state = parseListStateParams(searchParams, acceptField); + const carried = addressPanelFilterConditionCount(searchParams); + const refusedPanelFilter = carried > 0 && (state.filters?.conditions.length ?? 0) < carried; + if (refusedPanelFilter) delete state.filters; + listSeedRef.current = { key: listSeedKey, state, refusedPanelFilter }; + } + } + const listSeed = listSeedRef.current?.key === listSeedKey ? listSeedRef.current?.state : undefined; + React.useEffect(() => { + const seed = listSeedRef.current; + if (!seed || seed.key !== listSeedKey) return; + const next = applyListStateParams(searchParams, { + filters: seed.state.filters ?? null, + search: seed.state.search ?? null, + sort: seed.state.sort ?? null, + grouping: seed.state.grouping ?? null, + }); + if (next.toString() !== searchParams.toString()) setSearchParams(next, { replace: true }); + if (seed.refusedPanelFilter) { + seed.refusedPanelFilter = false; + toast.warning(t('console.objectView.linkFilterRefused')); + } + // Once per seed, by design: later writes are the list's own changes, + // already on screen. + // eslint-disable-next-line react-hooks/exhaustive-deps -- see above + }, [listSeedKey]); + /** Write the list's own change into the address — replace, never a history entry per keystroke. */ + const writeListUrlState = React.useCallback( + (patch: ListStatePatch) => { + setSearchParams((prev) => applyListStateParams(prev, patch), { replace: true }); + }, + [setSearchParams], + ); + // The chips' selections the list remounts with: the address's at mount; none + // after a 「Reset」, which cleared their params. + const listUserFilterSelections = listGeneration === 0 ? initialUfSelections : undefined; + // URL filter triples, trimmed to readable fields. Predicates on unreadable // fields are dropped here for UX honesty; the SERVER is the actual // enforcement point against filter-oracle probing. @@ -379,6 +502,10 @@ export function ObjectDataPage({ dataSource, objects }: any) { next.set(sourceFilterKey, source.i); return next; }); + // objectstack#36408 — the list's own state left with its `uf_` params: + // the list remounts on an empty seed (see `listSeedRef`). + listResetPendingRef.current = true; + setListGeneration((g) => g + 1); }, [source, sourceFilterKey, setSearchParams]); const removeUrlFilter = React.useCallback( @@ -540,6 +667,10 @@ export function ObjectDataPage({ dataSource, objects }: any) { viewType: 'grid' as const, columns, ...(urlFilters.length ? { filter: urlFilters } : {}), + // objectstack#36408 — the sort and the grouping the address carries + // (`uf__sort`, `uf__group`), read once per seed (see `listSeedRef`). + ...(listSeed?.sort ? { sort: listSeed.sort } : {}), + ...(listSeed?.grouping ? { grouping: listSeed.grouping } : {}), kanban, calendar, gallery, @@ -564,10 +695,12 @@ export function ObjectDataPage({ dataSource, objects }: any) { hideFields: true, }, showRecordCount: true, - // Deliberately NO onSortChange/onFilterChange persistence hooks: this - // surface never writes back to any saved view (#2251). + // Deliberately NO `onSortChange` / `onFilterChange` persistence hooks in + // the schema: this surface never writes back to any saved view (#2251). + // The list's own changes go to the ADDRESS only, through `ListView`'s + // host callbacks below (objectstack#36408). }; - }, [objectDef, columns, urlFilters, kanban, calendar, gallery, userFilters, allowedVisualizations]); + }, [objectDef, columns, urlFilters, listSeed, kanban, calendar, gallery, userFilters, allowedVisualizations]); // "Save as view" — the one exit into the workspace: materialize the current // URL conditions as a new saved view, then navigate to it. Resolves whether @@ -920,10 +1053,24 @@ export function ObjectDataPage({ dataSource, objects }: any) {
{schema && ( writeListUrlState({ search })} + onFilterChange={(filters) => writeListUrlState({ filters })} + // No sort is this page's own default, so a cleared sort leaves the address. + onSortChange={(sort) => writeListUrlState({ sort: sort.length > 0 ? sort : null })} + onGroupingChange={(grouping) => writeListUrlState({ grouping: grouping ?? null })} onRowClick={handleRecordClick} // objectstack#35854 — the name opens the full page; the icon // beside it, on hover, opens the record in the side drawer. From ca334774d6691815c3245d5c0d4e3e03f506ff98 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 22:46:03 +0000 Subject: [PATCH 2/2] test(app-shell): pin the /data list state kept in the address across a record's open and close, a reload and a Reset Claude-Session: https://claude.ai/code/session_01ADHkmRGDrq6JSytBsNFabU Co-authored-by: Claude --- .../36408-data-page-list-state-in-address.md | 12 ++ .../ObjectDataPage.openRule-35875.test.tsx | 202 ++++++++++++++++++ .../app-shell/src/views/ObjectDataPage.tsx | 23 +- 3 files changed, 231 insertions(+), 6 deletions(-) create mode 100644 .changeset/36408-data-page-list-state-in-address.md diff --git a/.changeset/36408-data-page-list-state-in-address.md b/.changeset/36408-data-page-list-state-in-address.md new file mode 100644 index 00000000000..cdc725d1940 --- /dev/null +++ b/.changeset/36408-data-page-list-state-in-address.md @@ -0,0 +1,12 @@ +--- +'@object-ui/app-shell': patch +--- + +fix(console): the bare data page keeps its list's search, sort, grouping and Filter panel when a record is opened and closed, and on a reload + +Clause-②: no +Metadata-protocol: none + +On the bare data page (`/apps/APP/OBJECT/data`) a search, a sort, a grouping or a Filter panel condition was lost as soon as the reader opened a record and came back, or reloaded the page: the page kept only its own URL conditions in its address. It now keeps the list's own state there too, under the same parameters an object's list uses (`uf__search`, `uf__sort`, `uf__group`, `uf__filter`), written with replace so typing a term adds no history entries. The record page's close, a reload and a copied link open the list as the reader left it. + +The page's own URL conditions (`filter[FIELD]`, the removable 「Filtered by」 tags) are unchanged and stay a separate layer: the list applies them and the Filter panel together, and changing one never rewrites the other. "Save as view" still saves only the URL conditions. A Filter panel in the address that names a field the object does not declare, or one the reader cannot read, is refused whole with the same notice an object's list shows. 「Reset」 on a list opened from a record's related list, which already removed every `uf_` parameter from the address, now also opens the list again without them: no search, sort, grouping, Filter panel or quick-filter selection is left applied on screen. diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.openRule-35875.test.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.openRule-35875.test.tsx index 3fca470f52e..a7590e8dd3c 100644 --- a/ui/packages/app-shell/src/views/ObjectDataPage.openRule-35875.test.tsx +++ b/ui/packages/app-shell/src/views/ObjectDataPage.openRule-35875.test.tsx @@ -347,3 +347,205 @@ describe('objectstack#36300 — the data page\'s side drawer draws ⤢ 「Open a expect(screen.queryByRole('dialog')).toBeNull(); }); }); + +/** + * objectstack#36408 — the data page's list keeps its own state in the address, + * under the keys `ObjectView` keeps it in: the search (`uf__search`), the sort + * (`uf__sort`), the grouping (`uf__group`) and the Filter panel (`uf__filter`). + * So the record page's ✕, which returns to the address the list was left at, + * and a reload of that address, open the list as the reader left it. The + * page's own address conditions (`filter[...]`) are a separate layer the list + * applies with the panel; neither rewrites the other. + */ +describe('objectstack#36408 — the data page keeps its list\'s search, sort, grouping and Filter panel in the address', () => { + const SOURCE_OBJECTS = [ + { + ...OBJECTS[0], + fields: { ...OBJECTS[0].fields, parent: { type: 'lookup', reference: 'demo_parent', label: 'Parent' } }, + }, + { name: 'demo_parent', label: 'Parent', pluralLabel: 'Parents', fields: { name: { type: 'text', label: 'Name' } } }, + ]; + const CITY_OSLO = { logic: 'and', conditions: [{ field: 'city', operator: 'equals', value: 'Oslo' }] }; + const BY_STATUS = { fields: [{ field: 'status', order: 'asc', collapsed: false }] }; + /** The list queries, newest last; the record-count probe (`$top: 0`) is left out. */ + let queries: Array> = []; + let groupQueries: Array<{ groupBy?: string[] }> = []; + const lastQuery = () => queries[queries.length - 1]; + const filterOf = (query: Record | undefined) => JSON.stringify(query?.$filter ?? null); + const addressParams = () => new URLSearchParams(search() ?? ''); + + function address(params: Record): string { + const sp = new URLSearchParams(); + for (const [key, value] of Object.entries(params)) { + sp.set(key, typeof value === 'string' ? value : JSON.stringify(value)); + } + return `?${sp.toString()}`; + } + + async function mountAt(entrySearch: string, objects: unknown[] = OBJECTS, waitForRows = true) { + queries = []; + groupQueries = []; + const dataSource = { + find: vi.fn(async (_object: string, params: Record) => { + if (params?.$top !== 0) queries.push(params); + return { data: ROWS, total: MATCHED }; + }), + findOne: vi.fn(async () => null), + // A grouped grid asks the server for its groups; recorded so a case can + // read which fields the list is grouped by. + queryGroupHeaders: vi.fn(async (_object: string, query: { groupBy?: string[] }) => { + groupQueries.push(query); + return []; + }), + create: vi.fn(async () => ({})), + update: vi.fn(async () => ({})), + delete: vi.fn(async () => ({})), + getObjectSchema: vi.fn(async (name: string) => (objects as Array<{ name: string }>).find((o) => o.name === name) ?? null), + } as never; + window.history.replaceState(null, '', DATA_PATH); + render( + + + + + + } /> + } /> + + + + + + , + ); + if (waitForRows) await screen.findByText('Globex', undefined, { timeout: 5000 }); + else await waitFor(() => expect(queries.length).toBeGreaterThan(0), { timeout: 5000 }); + await settle(); + } + + /** The record's full page by its name, then the page's ✕ back to the data page. */ + async function openAndClose(name: string) { + clickName(name); + await screen.findByTestId('record-page', undefined, { timeout: 5000 }); + const from = JSON.parse(screen.getByTestId('record-from').textContent ?? 'null'); + fireEvent.click(screen.getByTestId('record-close')); + await screen.findByText('Globex', undefined, { timeout: 5000 }); + await settle(); + return from as { pathname: string }; + } + + it('a search, then a record opened and closed: the search is still applied', async () => { + await mountAt(DATA_SEARCH); + fireEvent.click(screen.getByTestId('search-icon-button')); + fireEvent.change(screen.getByPlaceholderText(/search/i), { target: { value: 'Acm' } }); + await settle(); + expect(addressParams().get('uf__search')).toBe('Acm'); + expect(lastQuery().$search).toBe('Acm'); + fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); + await settle(); + + const from = await openAndClose('Acme'); + // The record page's origin is the address with the search in it. + expect(new URLSearchParams(from.pathname.split('?')[1]).get('uf__search')).toBe('Acm'); + expect(pathname()).toBe(DATA_PATH); + expect(addressParams().get('uf__search')).toBe('Acm'); + expect(addressParams().get('filter[status]')).toBe('active'); + // The list the close returned to searches, and says so on its toolbar. + expect(lastQuery().$search).toBe('Acm'); + expect(screen.getByTestId('search-active-keyword').textContent).toBe('Acm'); + }); + + it('a reload of an address with a search, a sort and a Filter panel opens that list, on top of its own conditions', async () => { + await mountAt(address({ + 'filter[status]': 'active', + uf__search: 'Glo', + uf__sort: [{ field: 'city', order: 'desc' }], + uf__filter: CITY_OSLO, + })); + const q = lastQuery(); + expect(q.$search).toBe('Glo'); + expect(q.$orderby).toEqual([{ field: 'city', order: 'desc' }]); + // The two layers, both applied: the page's condition and the panel's. + expect(filterOf(q)).toContain('"status","=","active"'); + expect(filterOf(q)).toContain('"city","=","Oslo"'); + // Neither layer rewrote the other: the address keeps both as they came. + const params = addressParams(); + expect(params.get('filter[status]')).toBe('active'); + expect(JSON.parse(params.get('uf__filter')!)).toEqual(CITY_OSLO); + expect(JSON.parse(params.get('uf__sort')!)).toEqual([{ field: 'city', order: 'desc' }]); + // The panel condition is the list's, not one of the page's 「Filtered by」 tags. + expect(screen.queryByTestId('object-data-remove-filter-city')).toBeNull(); + expect(screen.getByTestId('object-data-remove-filter-status')).toBeTruthy(); + + // And they survive a record opened and closed. + const from = await openAndClose('Globex'); + expect(new URLSearchParams(from.pathname.split('?')[1]).get('uf__sort')).toBe(params.get('uf__sort')); + const back = lastQuery(); + expect(back.$search).toBe('Glo'); + expect(back.$orderby).toEqual([{ field: 'city', order: 'desc' }]); + expect(filterOf(back)).toContain('"status","=","active"'); + expect(filterOf(back)).toContain('"city","=","Oslo"'); + }); + + it('a reload of an address with a grouping groups the list, and the address keeps it', async () => { + await mountAt(address({ uf__group: BY_STATUS }), OBJECTS, false); + await waitFor(() => expect(groupQueries.length).toBeGreaterThan(0), { timeout: 5000 }); + expect(groupQueries[groupQueries.length - 1].groupBy).toEqual(['status']); + expect(JSON.parse(addressParams().get('uf__group')!)).toEqual(BY_STATUS); + }); + + it('CONTROL — an address without list state: no search, no sort, no grouping, and none is written', async () => { + await mountAt(DATA_SEARCH); + const q = lastQuery(); + expect(q.$search).toBeUndefined(); + expect(q.$orderby ?? []).toEqual([]); + expect(groupQueries).toHaveLength(0); + for (const key of ['uf__search', 'uf__sort', 'uf__group', 'uf__filter']) { + expect(addressParams().has(key)).toBe(false); + } + }); + + it('a Filter panel naming a field the object does not declare is refused whole, and leaves the address', async () => { + await mountAt(address({ + 'filter[status]': 'active', + uf__filter: { logic: 'and', conditions: [{ field: 'ghost', operator: 'equals', value: 'x' }, ...CITY_OSLO.conditions] }, + })); + for (const q of queries) { + expect(filterOf(q)).not.toContain('ghost'); + expect(filterOf(q)).not.toContain('Oslo'); + } + expect(addressParams().has('uf__filter')).toBe(false); + expect(addressParams().get('filter[status]')).toBe('active'); + }); + + it('「Reset」 to the source clears the list\'s search with its address param, and the list stops searching', async () => { + const trail = JSON.stringify([{ o: 'demo_parent', i: 'P-1', t: 'Launch' }]); + await mountAt(address({ 'filter[parent]': 'P-1', 'filter[status]': 'active', from: trail, uf__search: 'Glo' }), SOURCE_OBJECTS); + expect(lastQuery().$search).toBe('Glo'); + const reset = screen.getByTestId('object-data-reset-source') as HTMLButtonElement; + expect(reset.disabled).toBe(false); + fireEvent.click(reset); + await screen.findByText('Globex', undefined, { timeout: 5000 }); + await settle(); + expect(addressParams().has('uf__search')).toBe(false); + expect(addressParams().get('filter[parent]')).toBe('P-1'); + expect(addressParams().has('filter[status]')).toBe(false); + // The list on screen is the address's: no search term left in it. + expect(lastQuery().$search).toBeUndefined(); + expect(screen.queryByTestId('search-active-keyword')).toBeNull(); + expect((screen.getByTestId('object-data-reset-source') as HTMLButtonElement).disabled).toBe(true); + }); + + it('a sort the reader removes leaves the address, and the list asks for none', async () => { + await mountAt(address({ 'filter[status]': 'active', uf__sort: [{ field: 'city', order: 'desc' }] })); + expect(lastQuery().$orderby).toEqual([{ field: 'city', order: 'desc' }]); + fireEvent.click(await within(screen.getByTestId('list-condition-row')).findByTestId('condition-sort')); + const row = await screen.findByTestId('sort-builder-row'); + fireEvent.click(within(row).getByRole('button', { name: 'Remove sort' })); + await settle(); + expect(addressParams().has('uf__sort')).toBe(false); + expect(lastQuery().$orderby ?? []).toEqual([]); + // No sort is this page's own: the list offers no 「Reset to default」 for the address's. + expect(screen.queryByTestId('sort-reset-default')).toBeNull(); + }); +}); diff --git a/ui/packages/app-shell/src/views/ObjectDataPage.tsx b/ui/packages/app-shell/src/views/ObjectDataPage.tsx index 82cfea59011..b524303191d 100644 --- a/ui/packages/app-shell/src/views/ObjectDataPage.tsx +++ b/ui/packages/app-shell/src/views/ObjectDataPage.tsx @@ -292,8 +292,8 @@ export function buildSaveAsViewSpec( * objectstack#36408 — this page's own list defaults, for `ListView`'s * `viewDefaults`: no sort and no grouping (the page has no view to declare * either), the hidden fields and row height its `schema` never sets. The - * sort and grouping `schema` carries are the address's, so the list's - * 「Reset to default」 returns to these rather than to the address's. + * sort and grouping `schema` carries are the address's, never a default the + * list should offer to return to. */ const DATA_PAGE_LIST_DEFAULTS = { hiddenFields: undefined, rowHeight: undefined, sort: undefined, grouping: undefined }; @@ -393,13 +393,19 @@ export function ObjectDataPage({ dataSource, objects }: any) { */ const [listGeneration, setListGeneration] = React.useState(0); const listResetPendingRef = React.useRef(false); - const listSeedRef = React.useRef<{ key: string; state: ListUrlState; refusedPanelFilter?: boolean } | undefined>(undefined); + const listSeedRef = React.useRef<{ + key: string; + state: ListUrlState; + /** Taken by a 「Reset」, which wrote the address itself. */ + reset?: boolean; + refusedPanelFilter?: boolean; + } | undefined>(undefined); const listSeedKey = objectDef ? `${objectDef.name}~${listGeneration}` : undefined; if (objectDef && listSeedKey && listSeedRef.current?.key !== listSeedKey) { const reset = listResetPendingRef.current; listResetPendingRef.current = false; if (reset) { - listSeedRef.current = { key: listSeedKey, state: {} }; + listSeedRef.current = { key: listSeedKey, state: {}, reset: true }; } else { const acceptField: ListUrlFieldGate = (field: string) => !!objectDef.fields?.[field] @@ -414,7 +420,11 @@ export function ObjectDataPage({ dataSource, objects }: any) { const listSeed = listSeedRef.current?.key === listSeedKey ? listSeedRef.current?.state : undefined; React.useEffect(() => { const seed = listSeedRef.current; - if (!seed || seed.key !== listSeedKey) return; + // A 「Reset」's seed writes nothing: the reset already cleared the + // address, and the location this render read may still be the one before + // it (the router commits a navigation in a transition), so a write from + // it would put the cleared conditions back. + if (!seed || seed.key !== listSeedKey || seed.reset) return; const next = applyListStateParams(searchParams, { filters: seed.state.filters ?? null, search: seed.state.search ?? null, @@ -1062,7 +1072,8 @@ export function ObjectDataPage({ dataSource, objects }: any) { // grouping: opened from the address, and every change written // back to it (replace). `schema` carries the address's sort and // grouping, so this page's own defaults — no sort, no grouping — - // are handed apart, for the list's 「Reset to default」. + // are handed apart: the address's sort is no default this page + // declares (the list draws no 「Reset to default」 for it). initialSearchTerm={listSeed?.search} initialFilters={listSeed?.filters} viewDefaults={DATA_PAGE_LIST_DEFAULTS}