diff --git a/.changeset/34722-installed-apps-module-toggle-aria-controls.md b/.changeset/34722-installed-apps-module-toggle-aria-controls.md new file mode 100644 index 00000000000..6e5920fc6d5 --- /dev/null +++ b/.changeset/34722-installed-apps-module-toggle-aria-controls.md @@ -0,0 +1,10 @@ +--- +'@object-ui/app-shell': patch +--- + +fix(app-shell): the Installed Apps module toggle names the module lines it shows + +Clause-②: no +Metadata-protocol: none + +In Setup › Installed Apps, the button that shows and hides an app's modules carried `aria-controls` with an id that no element had, so a screen reader was pointed at nothing. Each module line now has its own id. While the modules are shown, the button's `aria-controls` lists those ids. While they are hidden, the lines are not drawn and the button has no `aria-controls`. `aria-expanded` is unchanged. diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx index 13227fe677a..20f9a14ee32 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx @@ -34,6 +34,7 @@ import '@testing-library/jest-dom/vitest'; import { afterEach, describe, expect, it, vi } from 'vitest'; import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; +import axe from 'axe-core'; import { I18nProvider } from '@object-ui/i18n'; vi.mock('@object-ui/auth', async (importOriginal) => ({ @@ -346,6 +347,35 @@ describe('Setup → Installed Apps: an app is one line, its modules folded under for (const id of MODULE_IDS) expect(screen.queryByTestId(`pkg-row-${id}`)).toBeNull(); }); + it('the toggle names the module lines it shows in aria-controls, and names none while they are hidden', async () => { + await serve({ packages: [HOTCRM, ...MODULES, TODO] }); + renderAt(SETUP_URL); + await settled(); + + const toggle = screen.getByTestId(`pkg-modules-toggle-${HOTCRM_ID}`); + expect(toggle).not.toHaveAttribute('aria-controls'); + + fireEvent.click(toggle); + const ids = (toggle.getAttribute('aria-controls') ?? '').split(' '); + // Every id resolves to a drawn module line of this app, one per module. + const named = ids.map((id) => document.getElementById(id)); + expect(named.map((el) => el?.getAttribute('data-testid')).sort()).toEqual( + MODULE_IDS.map((id) => `pkg-row-${id}`).sort(), + ); + for (const el of named) expect(el).toHaveAttribute('data-module-of', HOTCRM_ID); + + // axe judges the IDREFs of an expanded control: none may dangle. + const res = await axe.run(screen.getByTestId('pkg-installed-apps-table'), { + runOnly: { type: 'rule', values: ['aria-valid-attr-value'] }, + }); + expect(res.violations.map((v) => v.nodes.map((n) => n.html.slice(0, 80)))).toEqual([]); + // Control: an empty list is a reading only if the rule judged the toggle. + expect(res.passes.flatMap((r) => r.nodes.map((n) => n.html)).some((h) => h.includes('aria-controls='))).toBe(true); + + fireEvent.click(toggle); + expect(toggle).not.toHaveAttribute('aria-controls'); + }); + it('a module that declares two apps, or none in view, stays a line of its own', async () => { const twoApps = moduleOf(`${HOTCRM_ID}.bridge`, [HOTCRM_ID, 'com.example.todo']); const orphan = moduleOf('com.example.lonely', ['com.example.absent']); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index e5b25b5dd69..049bd99f62b 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -465,6 +465,17 @@ function appOfModule(row: PackageListRow, apps: ReadonlyMap(); @@ -1818,6 +1829,7 @@ export function PackagesPage() { .filter((g): g is InstalledAppGroup & { matchedModules: boolean } => g !== null); }, [installedAppsView, rows, query]); const [expandedApps, setExpandedApps] = React.useState>(() => new Set()); + const moduleIdBase = React.useId(); const toggleApp = (id: string) => setExpandedApps((prev) => { const next = new Set(prev); @@ -2128,6 +2140,7 @@ export function PackagesPage() { key={rowId} className={cn(p ? 'cursor-pointer' : undefined, module ? 'bg-muted/30' : undefined)} onClick={p ? () => openDetail(p) : undefined} + id={module ? moduleRowDomId(moduleIdBase, rowId) : undefined} data-testid={`pkg-row-${rowId}`} data-module-of={module ? row.id : undefined} > @@ -2139,7 +2152,11 @@ export function PackagesPage() { size="icon" className="h-6 w-6 shrink-0" aria-expanded={open} - aria-controls={`pkg-modules-${rowId}`} + // The module lines it shows and hides: named only while + // they are drawn, since a collapsed group renders none. + aria-controls={ + open ? modules.map((m) => moduleRowDomId(moduleIdBase, m.id)).join(' ') : undefined + } aria-label={ open ? tFormat('engine.packages.installedApps.hideModules', locale, { name: p?.manifest.name || rowId })