From af729427434b9c59b7fdeffce79a573ad4c6cb1a Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 13:26:47 +0000 Subject: [PATCH 1/2] fix(plugin-detail): translate the related list count badge's accessible name Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4d1cnRvyiAqrarmDhZV --- .../src/RelatedList.i18n.test.tsx | 83 +++++++++++++++++++ ui/packages/plugin-detail/src/RelatedList.tsx | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 ui/packages/plugin-detail/src/RelatedList.i18n.test.tsx diff --git a/ui/packages/plugin-detail/src/RelatedList.i18n.test.tsx b/ui/packages/plugin-detail/src/RelatedList.i18n.test.tsx new file mode 100644 index 00000000000..05904fd86d6 --- /dev/null +++ b/ui/packages/plugin-detail/src/RelatedList.i18n.test.tsx @@ -0,0 +1,83 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * A related list's header count badge speaks the session locale. + * + * The badge draws a bare number, so its `aria-label` is what a screen reader + * announces for it. It reads `detail.relatedRecordOne` at one record and + * `detail.relatedRecords` otherwise — the same pair the tab list's summary + * row lead reads — so a zh-CN console announces 「3 条记录」 and an English + * one never says "1 records". + */ +import { describe, it, expect, vi, beforeAll, afterEach } from 'vitest'; +import { cleanup, render, waitFor } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import React from 'react'; +import { I18nProvider } from '@object-ui/i18n'; +import { RelatedList } from './RelatedList'; + +beforeAll(() => { + Object.defineProperty(window, 'innerWidth', { configurable: true, value: 1280 }); +}); + +afterEach(() => cleanup()); + +const rows = (n: number) => Array.from({ length: n }, (_, i) => ({ id: `c${i + 1}`, name: `Contact ${i + 1}` })); + +function renderListIn(language: string, n: number) { + const find = vi.fn(async () => ({ data: rows(n), total: n })); + render( + + + , + ); +} + +/** The accessible name of the list header's count badge, once it draws `n`. */ +async function headBadgeName(n: number): Promise { + let name: string | null = null; + await waitFor(() => { + const badges = Array.from(document.querySelectorAll('[data-related-list-head] [aria-label]')) + .filter((el) => el.textContent === String(n)); + expect(badges).toHaveLength(1); + name = badges[0].getAttribute('aria-label'); + }); + return name; +} + +describe('related list count badge — accessible name is translated', () => { + it('announces the zh bundle value under a zh-CN session', async () => { + renderListIn('zh-CN', 3); + expect(await headBadgeName(3)).toBe('3 条记录'); + }); + + it('announces the singular under an en session at one record', async () => { + renderListIn('en', 1); + expect(await headBadgeName(1)).toBe('1 record'); + }); + + it('announces the plural under an en session', async () => { + renderListIn('en', 3); + expect(await headBadgeName(3)).toBe('3 records'); + }); + + it('announces the singular under a de session at one record', async () => { + renderListIn('de', 1); + expect(await headBadgeName(1)).toBe('1 Datensatz'); + }); +}); diff --git a/ui/packages/plugin-detail/src/RelatedList.tsx b/ui/packages/plugin-detail/src/RelatedList.tsx index 6159050c932..d16debe79e2 100644 --- a/ui/packages/plugin-detail/src/RelatedList.tsx +++ b/ui/packages/plugin-detail/src/RelatedList.tsx @@ -4758,7 +4758,7 @@ export const RelatedList: React.FC = ({ 'text-xs font-normal h-5 px-1.5', recordCount === 0 && 'bg-muted text-muted-foreground' )} - aria-label={`${recordCount} records`} + aria-label={tabRecordCountLead(recordCount)} > {recordCount} From 646a0f3a002f4dd8c32c173714ddc560b836d187 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 4 Dec 2026 13:42:59 +0000 Subject: [PATCH 2/2] fix(plugin-detail): badge selector reads either label form; changeset Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_016WV4d1cnRvyiAqrarmDhZV --- .changeset/39680-related-list-count-badge-name.md | 10 ++++++++++ .../__tests__/RelatedList.countPending-36235.test.tsx | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/39680-related-list-count-badge-name.md diff --git a/.changeset/39680-related-list-count-badge-name.md b/.changeset/39680-related-list-count-badge-name.md new file mode 100644 index 00000000000..49562776d64 --- /dev/null +++ b/.changeset/39680-related-list-count-badge-name.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-detail': patch +--- + +fix(plugin-detail): a related list's count badge announces its count in the console language + +Clause-②: no +Metadata-protocol: none + +The count badge in a related list's header showed a number and announced it to screen readers in English ("3 records") whatever the console language. It now reads the translated pair the related list already uses elsewhere: a zh-CN console announces 「3 条记录」, and an English console says "1 record" at one record rather than "1 records". What the badge draws is unchanged. diff --git a/ui/packages/plugin-detail/src/__tests__/RelatedList.countPending-36235.test.tsx b/ui/packages/plugin-detail/src/__tests__/RelatedList.countPending-36235.test.tsx index f1575af12e1..d0b7f977e99 100644 --- a/ui/packages/plugin-detail/src/__tests__/RelatedList.countPending-36235.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RelatedList.countPending-36235.test.tsx @@ -56,7 +56,7 @@ async function flush() { /** The list header's count badge (the only `N records` label in the head). */ const headBadge = () => - document.querySelector('[data-related-list-head] [aria-label$=" records"]')?.textContent ?? null; + document.querySelector('[data-related-list-head] [aria-label$=" records"], [data-related-list-head] [aria-label$=" record"]')?.textContent ?? null; const cardCount = () => document.querySelector('[data-related-card-count]')?.textContent ?? null; function renderList(find: ReturnType) {