Skip to content

Commit f577149

Browse files
committed
fix(plugin-grid): the list-page scope survives one of its two registrants unmounting
The page header and the view bar's trailing end register the same page column, and the header unmounts as the trailing mounts. The scope is now counted per column, so it goes only with its last registrant instead of relying on React's effect order. The checklist's bulk-actions step names the floating bar, and two comments say why legacy names stay in More and where the summary-row offset comes from. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgWRZyWba1HhfWN7hKy
1 parent 957a7fa commit f577149

5 files changed

Lines changed: 94 additions & 7 deletions

File tree

‎docs/qa/platform-checklist/areas/records-forms.json‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@
621621
"title": "List-view capability matrix: filter, search, sort, pagination, saved views, inline edit, export, visualization switcher, bulk/row actions, conditional formatting",
622622
"since": "v15",
623623
"status": "active",
624-
"revision": 13,
624+
"revision": 14,
625625
"priority": "P1",
626626
"surface": "browser",
627627
"personas": [
@@ -659,7 +659,7 @@
659659
"in the grid saved view (inlineEdit: true), edit one cell in place; save; capture the PATCH; re-read the row via API",
660660
"on in_progress, with the export grant from fixtures.requires[3] bound, open the 视图设置 (View settings) popover beside the view name — the Display popover, named 选项 (Options) until objectstack#35878 moved it there — Export sits in its footer ('Export as CSV / XLSX / JSON'), not as a separate toolbar button — and export each declared format (csv, xlsx, json); capture the requests and files. Without the grant the Export entries are absent and the route answers 403 EXPORT_NOT_PERMITTED — the opt-in working as designed, not a fail of the export variant",
661661
"open the visualization switcher on All Tasks; enumerate the offered types; switch through each",
662-
"on bulk_actions, select rows that are NOT done and run showcase_mark_done (per-record) — its visible gate, has(record.done) && record.done != true, judges each selected row, so a done row in the selection drops Mark Done from the selection actions the view bar's right end shows (since #35554 the list page has no bottom bulk bar; since #35878 the selection face is the view bar's right end, with ⋮ still last), or, over a mixed selection, the confirm reports the done rows not eligible and skipped (QA run #27438); either way the dispatch count stops matching the selection — and showcase_recalc_selection (aggregate — ONE dispatch: an api-type action, which the console sends through the action door, POST /api/v1/actions/showcase_task/showcase_recalc_selection with body {params:{_selectedIds:[…]}}; the server forwards those params flat to the action's own target /api/v1/apps/showcase/recalc in-process, buildApiActionRequest in packages/runtime/src/action-execution.ts, so the browser's network log shows the door request and no /recalc request); on legacy_row_actions confirm both named row actions resolve to live menu entries",
662+
"on bulk_actions, select rows that are NOT done and run showcase_mark_done (per-record) — its visible gate, has(record.done) && record.done != true, judges each selected row, so a done row in the selection drops Mark Done from the selection actions the floating selection bar shows (since #35678 one bar floats at the bottom centre of the list and the view bar does not change on selection; over three actions the rest are under 「更多」), or, over a mixed selection, the confirm reports the done rows not eligible and skipped (QA run #27438); either way the dispatch count stops matching the selection — and showcase_recalc_selection (aggregate — ONE dispatch: an api-type action, which the console sends through the action door, POST /api/v1/actions/showcase_task/showcase_recalc_selection with body {params:{_selectedIds:[…]}}; the server forwards those params flat to the action's own target /api/v1/apps/showcase/recalc in-process, buildApiActionRequest in packages/runtime/src/action-execution.ts, so the browser's network log shows the door request and no /recalc request); on legacy_row_actions confirm both named row actions resolve to live menu entries",
663663
"on Field Zoo, confirm the conditionalFormatting row highlight applies to Specimen — Full (f_lookup set) and not Specimen — Minimal",
664664
"at 1280×800 on a zh-CN session, read the list frame on All Tasks, then on its kanban view: no page bar (objectstack#35878): a 40px view bar with the object's icon and name, 「/」, ONE switcher trigger reading type icon → view name → record count → caret, and 「视图设置」 on the left, and the search icon, 「+ 新建」 and ⋮ (description, import, favorite) last on the right; under it a 40px condition row that is always drawn — dashed 「排序」 and 「筛选」 while no condition is set, one 「按 X 排序」 chip (with +N) and the filter chips once set — so the table's header does not move when a condition is set or reset; on the grid a 32px header and 33px rows at 13px; and, on a view whose columns declare a `summary`, each total under its own column with 「计数 N」 leftmost and no doubled colon. The kanban view draws the same two rows (objectstack#35548; the count beside the view name returns, after objectstack#34603 removed it)",
665665
"at 1280×800 with the sidebar open, read the left edges of the list page on All Tasks (a list whose columns fit) and on a list that scrolls sideways (stage one by showing every field of showcase_task through 视图设置 → 添加列): the view bar's object icon, the header's select-all box, each row's checkbox and the footer's record count each start 16px from the main area's left; the selection column is 40px on both lists and stays 40px, pinned at the left, after scrolling to the far right and back; no row shows a number and each row's checkbox shows without a hover; the view bar's last control, ⋮, ends its icon 16px from the right; at 375 wide no leading item sits closer than 12px to the left (objectstack#35663)"
@@ -832,7 +832,8 @@
832832
"change": "steps[11] and its acceptance clause added: the list page's left edge (objectstack#35663, epic #35547). The page bar's icon, the view bar's icon, the select-all box, every row's checkbox and the footer's count share one 16px line, the selection column is 40px at any width and under a sideways scroll, and the grid draws no row numbers (each row's checkbox shows at rest). No earlier clause changed",
833833
"ref": "#35663"
834834
},
835-
{ "revision": 13, "date": "2026-11-20", "change": "steps[6], [8], [10], [11] and the clauses acceptance[10] and acceptance[11] follow #35878: the list page draws two rows, not three. There is no page bar; the view bar leads with the object's icon and name, then the switcher and 「视图设置」 (was 「选项」), and ends with search, 「+ 新建」 and ⋮ last (#35678). The condition row is always drawn at 40px, so the frame clause reads condition row 40 where it read 'no condition row height', and the left-edge clause's first item is the view bar's object icon where it was the page bar's (the view icon no longer leads the bar). Filter N and Sort N left the bar for the condition row", "ref": "#35878" }
835+
{ "revision": 13, "date": "2026-11-20", "change": "steps[6], [8], [10], [11] and the clauses acceptance[10] and acceptance[11] follow #35878: the list page draws two rows, not three. There is no page bar; the view bar leads with the object's icon and name, then the switcher and 「视图设置」 (was 「选项」), and ends with search, 「+ 新建」 and ⋮ last (#35678). The condition row is always drawn at 40px, so the frame clause reads condition row 40 where it read 'no condition row height', and the left-edge clause's first item is the view bar's object icon where it was the page bar's (the view icon no longer leads the bar). Filter N and Sort N left the bar for the condition row", "ref": "#35878" },
836+
{ "revision": 14, "date": "2026-11-21", "change": "steps[8] follows #35678: the selection actions are in one bar floating at the bottom centre of the list, and the view bar no longer changes on selection; what Mark Done's visible gate does is unchanged", "ref": "#35678" }
836837
]
837838
},
838839
{

‎ui/packages/components/src/renderers/complex/data-table.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5482,6 +5482,8 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
54825482
<div
54835483
className={cn(
54845484
"absolute inset-x-0 flex justify-center px-4",
5485+
// 2.0625rem is the summary row's h-8 plus its 1px border-t:
5486+
// the bar sits 1rem above the row instead of over it.
54855487
summaryRow ? "bottom-[calc(2.0625rem+1rem)]" : "bottom-3",
54865488
)}
54875489
>
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
* objectstack#35678 — the list-page scope is counted per page column. The page
11+
* header and the view bar's trailing end both register the same column, and
12+
* one unmounts as the other mounts; the column stays a list page until its
13+
* LAST registrant goes, whatever order React runs their effects in.
14+
*/
15+
import '@testing-library/jest-dom/vitest';
16+
import { render, screen, cleanup } from '@testing-library/react';
17+
import { describe, it, expect, afterEach } from 'vitest';
18+
import React from 'react';
19+
import { useListPageScope, useIsListPageGrid } from '../listPageScope';
20+
21+
afterEach(cleanup);
22+
23+
const Registrant: React.FC<{ scope: HTMLElement }> = ({ scope }) => {
24+
useListPageScope(scope);
25+
return null;
26+
};
27+
28+
const Probe: React.FC<{ root: HTMLElement }> = ({ root }) => (
29+
<span data-testid="probe">{useIsListPageGrid(root) ? 'list page' : 'elsewhere'}</span>
30+
);
31+
32+
function column(): { scope: HTMLElement; grid: HTMLElement } {
33+
const scope = document.createElement('div');
34+
const grid = document.createElement('div');
35+
scope.appendChild(grid);
36+
document.body.appendChild(scope);
37+
return { scope, grid };
38+
}
39+
40+
describe('useListPageScope (objectstack#35678)', () => {
41+
it('two registrants of one column: unmounting one keeps the scope; unmounting both drops it', () => {
42+
const { scope, grid } = column();
43+
const view = (a: boolean, b: boolean) => (
44+
<>
45+
{a && <Registrant key="header" scope={scope} />}
46+
{b && <Registrant key="trailing" scope={scope} />}
47+
<Probe root={grid} />
48+
</>
49+
);
50+
const { rerender } = render(view(true, false));
51+
expect(screen.getByTestId('probe')).toHaveTextContent('list page');
52+
// The trailing end registers first, then the header goes, in the order
53+
// that dropped the scope while it was a plain set.
54+
rerender(view(true, true));
55+
rerender(view(false, true));
56+
expect(screen.getByTestId('probe')).toHaveTextContent('list page');
57+
rerender(view(false, false));
58+
expect(screen.getByTestId('probe')).toHaveTextContent('elsewhere');
59+
scope.remove();
60+
});
61+
62+
it('CONTROL: a grid outside every registered column is not a list page', () => {
63+
const { scope } = column();
64+
const outside = document.createElement('div');
65+
document.body.appendChild(outside);
66+
render(
67+
<>
68+
<Registrant scope={scope} />
69+
<Probe root={outside} />
70+
</>,
71+
);
72+
expect(screen.getByTestId('probe')).toHaveTextContent('elsewhere');
73+
scope.remove();
74+
outside.remove();
75+
});
76+
});

‎ui/packages/plugin-grid/src/components/SelectionBar.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ const SingleRecordActions: React.FC<{ menu: RowActionMenuProps; fit: number; onC
159159
const all = singleRecordEntries(plan);
160160
const { exposed, rest } = planExposedEntries(
161161
all,
162+
// Over the budget, only declared actions and Edit become buttons: a legacy
163+
// `rowActions` name has no declared label (the menu title-cases its id),
164+
// so it stays in 「更多」 with Delete.
162165
(entry) => entry.kind === 'def' || entry.kind === 'edit',
163166
SELECTION_EXPOSED_ACTIONS,
164167
fit,

‎ui/packages/plugin-grid/src/listPageScope.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626

2727
import React from 'react';
2828

29-
const scopes = new Set<HTMLElement>();
29+
// Counted, not a set: two registrants may hold one page column (the page
30+
// header and the view bar's trailing end both do, and one unmounts as the
31+
// other mounts), so the scope goes only when its last registrant does.
32+
const scopes = new Map<HTMLElement, number>();
3033
const listeners = new Set<() => void>();
3134

3235
function emit(): void {
@@ -44,18 +47,20 @@ function subscribe(listener: () => void): () => void {
4447
export function useListPageScope(scope: HTMLElement | null): void {
4548
React.useLayoutEffect(() => {
4649
if (!scope) return undefined;
47-
scopes.add(scope);
50+
scopes.set(scope, (scopes.get(scope) ?? 0) + 1);
4851
emit();
4952
return () => {
50-
scopes.delete(scope);
53+
const left = (scopes.get(scope) ?? 1) - 1;
54+
if (left > 0) scopes.set(scope, left);
55+
else scopes.delete(scope);
5156
emit();
5257
};
5358
}, [scope]);
5459
}
5560

5661
function inScope(el: HTMLElement | null): boolean {
5762
if (!el) return false;
58-
for (const scope of scopes) if (scope.contains(el)) return true;
63+
for (const scope of scopes.keys()) if (scope.contains(el)) return true;
5964
return false;
6065
}
6166

0 commit comments

Comments
 (0)