Skip to content

Commit 04e7b90

Browse files
fix(components): badge page:tabs tabs whose related list binds its parent by parentDataSource (#34264)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9DWZEpY9vJu5mawox5gNXXf)_ Fixes #34250 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:应用页上的 `page:tabs`,标签里的关联列表如果用 `parentDataSource` 绑定父记录,标签在打开前就显示数量徽标;列表自己把它显示的条数报给所在标签,该标签预先挂载(隐藏)。 - 为什么改:云端 Team 页的「邀请」标签发出邀请后没有数字,只有点开才看到;原因是徽标只按页面的记录去计数,应用页没有记录。 - 风险与回滚:每个这样的标签在页面加载时多读一次父记录和一页子记录(默认 5 行);记录页上没有绑定的关联列表计数方式不变。回滚即还原本 PR。 - 先看:`ui/packages/components/src/renderers/layout/containers.tsx`(哪些标签预挂载、哪些列表不再探测)、`ui/packages/plugin-detail/src/RelatedList.tsx`(上报时机)、`ui/packages/plugin-detail/src/renderers/record-related-list.tsx`(只在绑定父记录时上报)。 - 两分钟验证:`cd ui && pnpm exec vitest run packages/plugin-detail/src/renderers/__tests__/record-related-list.parentDataSource-12294.test.tsx`,预期 16 个用例全过,其中 5 个是本卡新增。 - 需要你做的:无,席位落地。 ## What changes - `page:tabs` (`containers.tsx`): a `record:related_list` whose `parentDataSource` is a binding (`isElementDataSourceConfig`, the predicate `ParentRecordBinding` reads it by) is no longer probed by the strip, and a tab that holds such a list (among the lists its gates let the badge count) is kept mounted while inactive, the way a `list-view` tab already is (objectstack#26613). - `record:related_list` (`record-related-list.tsx`): when its parent is bound by `parentDataSource`, it hands its panel's count reporter (`usePageTabCountReporter`) to the list through a package-internal context, `RelatedListTotalReportContext` (`relatedListCompact.ts`, not exported from the package entry, so no public prop is added). - `RelatedList`: reports the number its header shows (`recordCount`) once its read has settled; a list still reading, whose read failed or whose filter was refused says nothing. Route: the card offered (a) resolving the probe's parent from `parentDataSource`, or (b) the list reporting its count. (a) cannot reuse the list's own parent read: that read is `BoundRecordProvider`, module-private in `@object-ui/plugin-detail`, and `@object-ui/components` cannot import from `@object-ui/plugin-detail` (the dependency runs the other way), so (a) would mean a second hand-written parent read beside it. (b) reuses the list's own parent binding, scope and filter, and the #26613 force-mount gives the number before the tab is opened. Invalidation: there is no new `RelatedCountStore` key. A create or delete on the child object reaches the list through the data-change bus (`notifyDataChanged` dispatches the `objectui:related-changed` event `RelatedList` re-reads on), and the re-read reports the new number. Pinned below. Unchanged: lists whose parent is the page's record are probed with the same store keys and the same invalidation; an authored `count` on a tab item still wins and leaves the tab mounted on open only. ## Why The hosted console Team page (objectstack-ai/cloud#4304, item 4) is an app page whose tabs are related lists bound to the current organization by `parentDataSource`. The strip keyed its probe on `ctx?.recordId`, which an app page does not have, so no badge was drawn. On a record page the same list was probed against the page's record, which is not its parent, so the badge counted the wrong parent's rows. ## Tests Five pins, a new top-level `describe` in the existing harness `record-related-list.parentDataSource-12294.test.tsx` (the REAL `page:tabs` around the REAL block): 1. App page: the Members tab is badged `2` (the bound parent's rows) while the first tab is still active; every child read is scoped to the bound parent. 2. A create, then a delete, on the child object (announced through `notifyDataChanged`) moves the badge 2 → 3 → 2. 3. An authored `count: 7` wins, and the inactive tab reads nothing (no parent read, no child read). 4. CONTROL, record page, unbound list: exactly one child read, the strip's `$top: 1` probe keyed on the page's record; the list is not mounted. 5. Record page, bound list: the badge is the bound parent's count; no child read uses the page's record. No existing test was edited. <details><summary>Ablations (each leg through scripts/ablation-replace.mjs; mutation landed and restored with blob == HEAD)</summary> | Leg | Mutation | Result | |:--|:--|:--| | 1 | `containers.tsx`: the force-mount arm for a parent-bound list replaced by `false` | 3 failed / 13 passed (pins 1, 2, 5) | | 2 | `containers.tsx`: the probe exclusion disabled | 1 failed / 15 passed (pin 5: badge counts the page record too) | | 3 | `RelatedList.tsx`: the report call removed | 3 failed / 13 passed (pins 1, 2, 5) | | 4 | `record-related-list.tsx`: the reporter never handed down | 3 failed / 13 passed (pins 1, 2, 5) | Vitest resolves `@object-ui/*` to source here, so each leg ran against the mutated source with no build step. </details> <details><summary>Page-load cost (asked for by the seat): an app page with two parent-bound tabs, neither opened</summary> A throwaway harness (not committed): `page:tabs` with Overview (active), Members (30 members) and Invitations (3 invitations), each list bound to one `sys_organization` row by `parentDataSource`, spec default `limit` 5. - Base `7be32d39`: 0 `find` calls, no badges. - This head: 4 `find` calls — `sys_organization` `$top: 1` twice (each list's parent read), `sys_member` `$top: 5` (5 rows), `sys_invitation` `$top: 5` (3 rows); badges `Members 30`, `Invitations 3`. Plus 6 `getObjectSchema` calls (parent and child object per list, the reads the lists make when shown). - Route (a) would also send 2 reads per tab (a parent read and a one-row count probe); the difference is the up-to-`limit` rows each hidden list loads. </details> ## Acceptance notes - `usePageTabCountReporter` returns a fresh function each render, so the list's report effect re-runs on each render; `report` returns the previous state for an equal count, so it causes no extra render. Same as the `list-view` reporter today. - A list whose re-read fails after a success keeps its last reported number on the badge (the reporter has no withdraw short of unmount), as a `list-view` tab does. - `ui` lint on the five touched files: 0 errors (warnings are pre-existing `any` and fast-refresh notices; one new `any` in `isParentBoundList(rl: any)`, matching the walk helpers beside it). ## Verification Head `eb87f29c`. <details><summary>Local runs</summary> - `pnpm --filter @object-ui/components --filter @object-ui/plugin-detail type-check` — exit 0 (both packages, `tsc --noEmit` and `tsconfig.test.json`). - `cd ui && pnpm exec vitest run packages/plugin-detail/` (whole package) — Test Files 379 passed, 1 skipped (380); Tests 3388 passed, 18 skipped. - `cd ui && pnpm exec vitest run` over the 26 components test files naming `page:tabs`, `RelatedCountStore` or `usePageTabCountReporter` — Test Files 26 passed; Tests 221 passed. The rest of `@object-ui/components` and the app-shell consumers are left to CI's Test UI shards (narrowed, declared). - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` — 38 derived families, each run, all exit 0; `--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. (not touched) - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmR5vV6DUixezqnpkyP)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 8fd5004 commit 04e7b90

6 files changed

Lines changed: 206 additions & 15 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@object-ui/components': patch
3+
'@object-ui/plugin-detail': patch
4+
'@object-ui/console': patch
5+
---
6+
7+
fix(components): a `page:tabs` tab holding a related list bound by `parentDataSource` shows its count badge before it is opened, on an app page too
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
The tab strip counts a `record:related_list` by probing it against the record the page is about. An app page has no such record, so a tab whose related list reads its parent through `parentDataSource` (a team page listing members and invitations of the current organization, say) drew no badge: the number showed only inside the opened tab. On a record page the same list was probed against the page's record, which is not its parent.
13+
14+
Such a list now says how many records it holds to its tab, the same number its own header shows, and the strip keeps that tab mounted while inactive so the badge is there before the tab is opened. A create or delete on the listed object re-reads the list and moves the badge. Lists whose parent is the page's record are counted by the strip's own probe exactly as before, and an authored `count` on a tab still wins.

‎ui/packages/components/src/renderers/layout/containers.tsx‎

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import React from 'react';
2222
import { createPortal } from 'react-dom';
23-
import { ComponentRegistry, ExpressionEvaluator, declaredNameField, evalRowPredicate, formatTitleTemplate, hasDeclaredPredicate, getRecordDisplayName, isActionSwitchedOff, recordDisplayValueAt, resolveNameField, toPredicateRecord } from '@object-ui/core';
23+
import { ComponentRegistry, ExpressionEvaluator, declaredNameField, isElementDataSourceConfig, evalRowPredicate, formatTitleTemplate, hasDeclaredPredicate, getRecordDisplayName, isActionSwitchedOff, recordDisplayValueAt, resolveNameField, toPredicateRecord } from '@object-ui/core';
2424
import type { ComponentInput } from '@object-ui/core';
2525
import { actionRendersAt, placedHeaderActions, resolveDeclaredActionIds } from '@object-ui/types';
2626
import type { DeclaredActionsRefusal } from '@object-ui/types';
@@ -596,6 +596,25 @@ const collectRelatedLists = (
596596
return acc;
597597
};
598598

599+
/**
600+
* objectstack#34250 — whether a collected `record:related_list` reads its
601+
* PARENT from a `parentDataSource` binding of its own. Such a list hangs off the
602+
* record its binding answers, not off the record context around the strip: on
603+
* an app page there is none, and on a record page the page's record is not
604+
* this list's parent. So the strip never probes it (it cannot name the parent
605+
* to count for); the list reports the number it holds through its panel's
606+
* count channel instead, and the tab is kept mounted while inactive so it can.
607+
*
608+
* Both doors the list itself is authored through are read, as `objectName` is
609+
* read below: the `properties` bag (the spec's props door, which
610+
* `SchemaRenderer` hoists for the list) and the hoisted key. The predicate is
611+
* the one the list's own parent scope (`ParentRecordBinding` in
612+
* `@object-ui/plugin-detail`) reads the binding by, so a value it would ignore
613+
* leaves the list on the strip's probe, keyed on the page's record as before.
614+
*/
615+
const isParentBoundList = (rl: any): boolean =>
616+
isElementDataSourceConfig(rl?.properties?.parentDataSource ?? rl?.parentDataSource);
617+
599618
/**
600619
* One count probe: which collection to count, scoped how.
601620
*
@@ -900,7 +919,9 @@ const PageTabsRenderer: React.FC<any> = ({ schema, className, ...props }) => {
900919
if (itemGated && !recordLoaded) return;
901920
const lists = shownListsByItem[idx]
902921
.filter((entry) => recordLoaded || entry.gates.length === 0)
903-
.map((entry) => entry.node);
922+
.map((entry) => entry.node)
923+
// objectstack#34250 — a parent-bound list reports its own number.
924+
.filter((rl) => !isParentBoundList(rl));
904925
const probes: Array<Probe> = [];
905926
for (const rl of lists) {
906927
const objectName: string | undefined = rl?.properties?.objectName || rl?.objectName;
@@ -1104,7 +1125,13 @@ const PageTabsRenderer: React.FC<any> = ({ schema, className, ...props }) => {
11041125
// objectstack#26613 — a tab whose badge its list blocks answer is
11051126
// mounted while inactive, so they run their queries; an authored count
11061127
// needs none of that, and leaves the tab mounted on open only.
1107-
reportsListCount: !authoredCount && containsListViewNode((it as any).children),
1128+
// objectstack#34250 — a related list bound to its parent by
1129+
// `parentDataSource` answers its tab's badge the same way, so its tab
1130+
// is kept mounted too. Only a list the badge counts (its gates open).
1131+
reportsListCount:
1132+
!authoredCount &&
1133+
(containsListViewNode((it as any).children) ||
1134+
shownListsByItem[idx].some((entry) => isParentBoundList(entry.node))),
11081135
};
11091136
});
11101137

‎ui/packages/plugin-detail/src/RelatedList.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ import {
100100
RelatedEnlargeContext,
101101
RelatedListCompactContext,
102102
RelatedListEnlargedContext,
103+
RelatedListTotalReportContext,
103104
useSeenOnce,
104105
} from './relatedListCompact';
105106
import { relatedCardId } from './synth/relatedArrangement';
@@ -3065,6 +3066,17 @@ export const RelatedList: React.FC<RelatedListProps> = ({
30653066
React.useEffect(() => {
30663067
onEmptyChange?.(emptyAnswer);
30673068
}, [emptyAnswer, onEmptyChange]);
3069+
// objectstack#34250 — the number this list holds, said to the `page:tabs`
3070+
// panel around it when `record:related_list` hands down a reporter (its
3071+
// parent is bound by `parentDataSource`; see `RelatedListTotalReportContext`).
3072+
// The header's own count, said once the read has settled: a list still
3073+
// reading, whose read failed, or whose filter was refused holds no number
3074+
// yet, and says none.
3075+
const reportTotal = React.useContext(RelatedListTotalReportContext);
3076+
const settledTotal = loading || loadFailure || filterRefusal ? null : recordCount;
3077+
React.useEffect(() => {
3078+
if (settledTotal !== null) reportTotal?.(settledTotal);
3079+
}, [reportTotal, settledTotal]);
30683080
React.useEffect(() => {
30693081
if (enlargedFace && enlargedChip === 'all' && !filterActive && !loading && !loadFailure) setAllCount(recordCount);
30703082
}, [enlargedFace, enlargedChip, filterActive, loading, loadFailure, recordCount]);

‎ui/packages/plugin-detail/src/relatedListCompact.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@ export const RelatedListEnlargedContext = React.createContext(false);
9696
*/
9797
export const RelatedCardCountContext = React.createContext<number | null>(null);
9898

99+
/**
100+
* Where a related list reports how many records it holds (objectstack#34250):
101+
* the count channel of the `page:tabs` panel it sits in, handed down by
102+
* `record:related_list` when its parent is bound by `parentDataSource`, and
103+
* `undefined` everywhere else.
104+
*
105+
* A parent-bound list has no parent the tab strip can name: on an app page
106+
* there is no record context at all, and on a record page the page's record is
107+
* not this list's parent. So the strip cannot probe the count itself, and the
108+
* list says the number it holds, the one its own header shows, read off the
109+
* query that drew its rows. The strip keeps such a tab mounted while inactive,
110+
* so the number is there before the tab is opened. A list whose parent is the
111+
* page's record never reports: the strip counts it by its own probe, as before.
112+
*
113+
* Package-internal: not exported from the package entry.
114+
*/
115+
export const RelatedListTotalReportContext = React.createContext<((total: number) => void) | undefined>(undefined);
116+
99117
/**
100118
* Has `el` come near the viewport yet (objectstack#27056, Target 2: only the
101119
* cards in view read their rows)? A latch: once seen, a card keeps its rows

‎ui/packages/plugin-detail/src/renderers/__tests__/record-related-list.parentDataSource-12294.test.tsx‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { RecordContextProvider, SchemaRenderer, SchemaRendererProvider, notifyDa
3232
import type { DataSource, DeclaredNode } from '@object-ui/types';
3333
import { I18nProvider } from '@object-ui/i18n';
3434
import '../../index';
35+
import { RelatedCountStore } from '@object-ui/components';
3536

3637
/** `RelatedList` never reads over the network with an adapter; answered anyway, as the sibling suites do. */
3738
vi.stubGlobal('fetch', (async () => new Response(null, { status: 501 })) as unknown as typeof globalThis.fetch);
@@ -300,3 +301,110 @@ describe('record:related_list — the parent-read panel title reads the bundle (
300301
expect(panel).toHaveTextContent('upstream exploded');
301302
});
302303
});
304+
305+
/**
306+
* objectstack#34250 — a `page:tabs` badge for a related list bound by
307+
* `parentDataSource`. The strip derives a badge by probing each related list
308+
* against the record context around it, and an app page has none, so such a
309+
* list drew no badge: its count showed only once its tab was opened. The list
310+
* now says the number it holds through its panel's count channel (the
311+
* objectstack#26613 channel), and its tab is kept mounted while inactive so it
312+
* can. Lists whose parent is the page's record are probed exactly as before.
313+
*
314+
* The REAL `page:tabs` (from `@object-ui/components`) around the REAL block, so
315+
* the badge is read off the tab trigger the reader sees.
316+
*/
317+
describe('page:tabs badges a related list bound by `parentDataSource` (objectstack#34250)', () => {
318+
/** Two members under the bound parent `env-1`, one under `env-2`, one under the page record. */
319+
const TEAM: Row[] = [
320+
{ id: 'm-1', name: 'Alice', environment_id: 'env-1', environment_code: 'FIRST' },
321+
{ id: 'm-4', name: 'Dave', environment_id: 'env-1', environment_code: 'FIRST' },
322+
{ id: 'm-2', name: 'Bob', environment_id: 'env-2', environment_code: 'SECOND' },
323+
{ id: 'm-3', name: 'Carol', environment_id: 'env-page', environment_code: 'PAGE' },
324+
];
325+
const BOUND = { object: PARENT_OBJECT, filter: PRODUCTION, sort: BY_RANK };
326+
327+
/** A strip whose FIRST tab is active and whose second holds the list under test. */
328+
const tabs = (list: Row, membersItem: Row = {}) => ({
329+
type: 'page:tabs',
330+
id: 'team_tabs',
331+
items: [
332+
{ label: 'Overview', value: 'overview', children: [] },
333+
{ label: 'Members', value: 'members', children: [list], ...membersItem },
334+
],
335+
});
336+
337+
const triggerText = (value: string) =>
338+
Array.from(document.querySelectorAll('[role="tab"]')).find((t) => t.textContent?.startsWith(value))?.textContent;
339+
340+
afterEach(() => {
341+
RelatedCountStore._reset();
342+
});
343+
344+
it('on an app page the Members tab is badged with the bound parent\'s rows before it is opened', async () => {
345+
const adapter = makeAdapter({ parents: PARENTS, children: TEAM });
346+
mountOnAppPage(tabs(node(BOUND)), adapter);
347+
348+
await waitFor(() => expect(triggerText('Members')).toBe('Members2'));
349+
// Not opened: the first tab is still the active one.
350+
expect(screen.getByRole('tab', { name: /Members/ })).toHaveAttribute('aria-selected', 'false');
351+
expect(screen.getByRole('tab', { name: /Overview/ })).toHaveAttribute('aria-selected', 'true');
352+
// Every child read is scoped to the bound parent; nothing was counted
353+
// against a parent the page does not have.
354+
const childReads = readsOf(adapter, CHILD_OBJECT);
355+
expect(childReads.length).toBeGreaterThan(0);
356+
for (const params of childReads) expect(params.$filter).toEqual({ environment_id: 'env-1' });
357+
});
358+
359+
it('a create, then a delete, on the child object moves the badge', async () => {
360+
const store = { parents: PARENTS, children: TEAM.map((r) => ({ ...r })) };
361+
const adapter = makeAdapter(store);
362+
mountOnAppPage(tabs(node(BOUND)), adapter);
363+
await waitFor(() => expect(triggerText('Members')).toBe('Members2'));
364+
365+
// A create under the bound parent, announced the way every dataSource
366+
// write is (the mutation bridge calls the same bus).
367+
store.children.push({ id: 'm-5', name: 'Erin', environment_id: 'env-1', environment_code: 'FIRST' });
368+
act(() => notifyDataChanged({ objectName: CHILD_OBJECT, recordId: 'm-5' }));
369+
await waitFor(() => expect(triggerText('Members')).toBe('Members3'));
370+
371+
store.children = store.children.filter((r) => r.id !== 'm-1');
372+
act(() => notifyDataChanged({ objectName: CHILD_OBJECT, recordId: 'm-1' }));
373+
await waitFor(() => expect(triggerText('Members')).toBe('Members2'));
374+
});
375+
376+
it('an authored `count` wins, and the tab is not mounted to count', async () => {
377+
const adapter = makeAdapter({ parents: PARENTS, children: TEAM });
378+
mountOnAppPage(tabs(node(BOUND), { count: 7 }), adapter);
379+
380+
await waitFor(() => expect(triggerText('Members')).toBe('Members7'));
381+
// Settle a tick: nothing in the inactive tab reads anything.
382+
await act(async () => {
383+
await new Promise((r) => setTimeout(r, 20));
384+
});
385+
expect(readsOf(adapter, PARENT_OBJECT)).toEqual([]);
386+
expect(readsOf(adapter, CHILD_OBJECT)).toEqual([]);
387+
expect(triggerText('Members')).toBe('Members7');
388+
});
389+
390+
it('CONTROL — on a record page an unbound list is probed against the page record, and its tab is not mounted', async () => {
391+
const adapter = makeAdapter({ parents: PARENTS, children: TEAM });
392+
mountOnRecordPage(tabs(node()), adapter);
393+
394+
await waitFor(() => expect(triggerText('Members')).toBe('Members1'));
395+
// The strip's own one-row count probe, keyed on the page's record.
396+
const childReads = readsOf(adapter, CHILD_OBJECT);
397+
expect(childReads).toHaveLength(1);
398+
expect(childReads[0]).toMatchObject({ $top: 1, $filter: { environment_id: 'env-page' } });
399+
// The list itself never mounted: its row is not drawn.
400+
expect(screen.queryByText('Carol')).not.toBeInTheDocument();
401+
});
402+
403+
it('on a record page a bound list is counted for ITS parent, never probed against the page record', async () => {
404+
const adapter = makeAdapter({ parents: PARENTS, children: TEAM });
405+
mountOnRecordPage(tabs(node(BOUND)), adapter);
406+
407+
await waitFor(() => expect(triggerText('Members')).toBe('Members2'));
408+
for (const params of readsOf(adapter, CHILD_OBJECT)) expect(params.$filter).toEqual({ environment_id: 'env-1' });
409+
});
410+
});

‎ui/packages/plugin-detail/src/renderers/record-related-list.tsx‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,19 @@ import {
2929
import { useFieldPermissions, usePermissions } from '@object-ui/permissions';
3030
import { useObjectTranslation, pickLocalized } from '@object-ui/i18n';
3131
import { humanizeLabel } from '@object-ui/fields';
32+
import { usePageTabCountReporter } from '@object-ui/components';
3233
import {
3334
columnIdentity,
3435
elementDataSourceBlock,
36+
isElementDataSourceConfig,
3537
resolveAffordance,
3638
servedObjectPluralLabel,
3739
toPredicateRecord,
3840
type ElementDataSourceConfig,
3941
} from '@object-ui/core';
4042
import type { RecordRelatedListComponentProps } from '@object-ui/types';
4143
import { RelatedList } from '../RelatedList';
42-
import { RecordBodyTablesContext, RelatedListCompactContext } from '../relatedListCompact';
44+
import { RecordBodyTablesContext, RelatedListCompactContext, RelatedListTotalReportContext } from '../relatedListCompact';
4345
import { relatedCardId } from '../synth/relatedArrangement';
4446
import { useRecordAriaProps } from './recordComponentAria';
4547
import { ParentRecordBinding } from './recordBinding';
@@ -925,18 +927,28 @@ const RecordRelatedListBound: React.FC<RecordRelatedListRendererProps> = (props)
925927
const parentBinding = schema?.parentDataSource;
926928
// objectui#12920 — the parent-read panel's title reads the bundle.
927929
const { t } = useObjectTranslation();
930+
// objectstack#34250 — a list whose parent its own binding reads says how many
931+
// records it holds to the `page:tabs` panel around it, since no tab strip can
932+
// name that parent to count for it (`RelatedListTotalReportContext`). The
933+
// predicate is the one `ParentRecordBinding` reads the binding by, so the
934+
// list reports exactly when its parent is the bound one; the strip excludes
935+
// the same lists from its own probe by the same predicate.
936+
const reportTabCount = usePageTabCountReporter();
937+
const reportTotal = isElementDataSourceConfig(parentBinding) ? reportTabCount : undefined;
928938
return (
929-
<ParentRecordBinding
930-
binding={parentBinding}
931-
blockKey="record:related_list"
932-
testId="record-related-list-parent"
933-
errorTitle={t('element.relatedList.parentUnreadable', {
934-
defaultValue: 'This related list’s parent record could not be read',
935-
})}
936-
absent={<NoParentRecord object={parentBinding?.object} className={className} designer={splitDesigner(rest).designer} />}
937-
>
938-
<RecordRelatedListChildRows {...props} />
939-
</ParentRecordBinding>
939+
<RelatedListTotalReportContext.Provider value={reportTotal}>
940+
<ParentRecordBinding
941+
binding={parentBinding}
942+
blockKey="record:related_list"
943+
testId="record-related-list-parent"
944+
errorTitle={t('element.relatedList.parentUnreadable', {
945+
defaultValue: 'This related list’s parent record could not be read',
946+
})}
947+
absent={<NoParentRecord object={parentBinding?.object} className={className} designer={splitDesigner(rest).designer} />}
948+
>
949+
<RecordRelatedListChildRows {...props} />
950+
</ParentRecordBinding>
951+
</RelatedListTotalReportContext.Provider>
940952
);
941953
};
942954

0 commit comments

Comments
 (0)