Skip to content

Commit c0d6406

Browse files
fix(app-shell): the inbox bell names its unread count, and the console sidebar is a navigation landmark (#32372)
<!-- claude-projects-attribution: {"github_login":"huangyiirene"} --> _Requested by **Irene** · [project thread](https://claude.ai/code/project/chan_01TJXtQ1tVD26ecLDZxFS67x?thread=cmsg_01TJXtQ1tVD26ecLDZxFS67xSXoaF6hSeT7sjxcA7Ccxox)_ Fixes #32159 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:控制台右上角通知铃铛的无障碍名称从固定的 "Open inbox" 改为带数量的 "Notifications, 3 unread topics"(有待审批时再加 ", 1 pending approval");侧边栏导航包进一个 `nav` 地标 "App navigation"。界面外观不变。 - **为什么改**:读屏用户以前听不到铃铛上的未读数,也无法按地标跳到侧边栏。卡片另外两条(分组折叠按钮、手机侧栏按钮无名称)在 `main` 上实测已满足,只加保护性测试,未改代码(席位更正记录 6775284999)。 - **风险与回滚**:低。只动 `InboxPopover.tsx` 的 `aria-label` 与 `UnifiedSidebar.tsx` 的一个 `div`→`nav`;不新增翻译键(`en` 包 0 字节)。按名字 "Open inbox" 找铃铛的外部脚本需改用 "Notifications"。回滚即 revert。 - **先看**:`ui/packages/app-shell/src/layout/InboxPopover.tsx`(`ariaLabel` 的拼法)、`ui/packages/app-shell/src/layout/UnifiedSidebar.tsx`(`nav` 包裹位置)、`ui/packages/app-shell/src/layout/__tests__/LocalizedSidebarTrigger.appBar-12429.test.tsx`(新地标与手机抽屉 pin)。 - **两分钟验证**:打开控制台任一应用页,用浏览器无障碍面板看铃铛,名称应为 "Notifications, N unread topics…";侧栏应是一个名为 "App navigation" 的 navigation 地标。 - **需要你做的**:无,席位评审后落地。 ## What changes - **Inbox bell (`InboxPopover`).** The accessible name was `sidebar.inboxAriaLabel` ("Open inbox") whatever the badge said. The badge is content inside a button that has an `aria-label`, so the count was never part of the announced name. The name is now `sidebar.notifications` ("Notifications") followed by each non-zero addend of the badge, in the plural forms the popover's own breakdown line already uses (`notifications.badgeNotifications` / `notifications.badgeApprovals`, `_one` / `_other`): "Notifications, 3 unread topics", "Notifications, 1 unread topic", "Notifications, 3 unread topics, 1 pending approval"; "Notifications" alone with nothing waiting. The header bell and the `global:notifications` page block draw this same control, so both change. The visible badge and the "Inbox" tooltip are unchanged. - **Sidebar landmark (`UnifiedSidebar`).** The `div` wrapping the sidebar's content slot is now `nav aria-label="App navigation"` (`console.nav.menuLabel`, the label the `nav-menu` page block already uses). The `Sidebar` primitive is Shadcn-synced and draws a plain `div` on desktop and a dialog on a phone, so the landmark rides inside its content slot and reaches the drawer too. One landmark per open view: the desktop sidebar, or the phone drawer once it opens (the closed drawer is not drawn). Nothing nests it. - **No new strings.** `ui/packages/i18n/src/locales/en.ts` is untouched: +0 bytes. Every key used is already in every pack. - **Already met on `main` (no code change, pinned):** the nav-group disclosures are named by their group label and carry `aria-expanded` (`ui/packages/layout` untouched), and the sidebar trigger is "Toggle sidebar" with `aria-expanded` at every width. Premise correction recorded on the card as comment 6775284999. ## Tests All role-based (`getByRole('button', { name })`, `getByRole('navigation')`), driven through real clicks where state changes. - `InboxPopover.badgePlural-13133.test.tsx` (real i18next + shipped `en` pack), new `describe`: the bell's name with a count of 3 ("…, 3 unread topics"), of 1 ("…, 1 unread topic"), with approvals beside topics, and PRESERVATION with nothing waiting ("Notifications"). - `LocalizedSidebarTrigger.appBar-12429.test.tsx` (real `UnifiedSidebar` + real trigger), new `describe`: desktop has exactly one `navigation` named "App navigation" holding the entries and no nested `nav`; at 375 px the trigger `{ name: 'Toggle sidebar', expanded: false }` is clicked, the drawer then holds exactly one landmark, and the trigger reports `expanded: true`. - `UnifiedSidebar.groupDefaultOpen-13336.test.tsx`, new `describe`: a collapsed group is `{ name: 'Advanced', expanded: false }` (its count badge stays out of the name); clicking flips `expanded` under the same name; both disclosures sit inside the landmark. - Three existing files found the bell by the old name and now find it by `/^Notifications(,|$)/`: `InboxPopover.openingTab-11698`, `InboxPopover.phoneWidth-29076`, `global-page-blocks.render` (two sites). No assertion was removed. <details><summary>Ablations (each mutation landed on disk via <code>scripts/ablation-replace.mjs</code>, run, then restored; <code>git diff HEAD</code> empty after each)</summary> | Mutation | Result | |:--|:--| | bell: drop the unread-topics addend (`...(unreadTopics > 0` → `...(false`) | 3 count pins fail; the 3 breakdown pins and the zero-count preservation pin stay green | | landmark: `nav` → `nav role="presentation"` | 3 landmark pins fail (desktop, phone drawer, group-in-landmark); 10 pass | | group name: trigger text `{groupLabel}` → `{null}` (`ui/packages/layout`, never committed) | all 6 tests in the group file fail, the 3 new ones included | | group state: `aria-expanded={undefined}` on the trigger (never committed) | all 6 fail | | toggle name: `const label = ''` in `LocalizedSidebarTrigger` | 5 of 7 fail, the new phone landmark pin included | </details> ## Acceptance notes - The bell names the badge's two addends separately rather than "3 unread": the badge sums unread topics and pending approvals, and approvals are not "unread". The parts are joined with ", ", fixed in code, so no new key reaches the eager `en` pack. - The phone drawer's header (app name and "All apps") sits above the content slot, outside the landmark. It names the app and leads out of it; the landmark holds the app's navigation entries. ## Verification Measured in Chromium (Playwright `ariaSnapshot` + `getByRole`) against showcase `objectstack dev --fresh` and the console served by Vite from this tree's `ui/` source. | Reading | `main` `60b99f8f` | this branch | |:--|:--|:--| | bell | `button "Open inbox": "4"` | `button "Notifications, 1 unread topic, 3 pending approvals": "4"` | | `getByRole('navigation')`, desktop task list | 0 | 1, `navigation "App navigation"` | | phone 390 px, drawer open | 0 | 1; `nav nav` = 0; closed drawer 0 | | group disclosures | `button "Workspace" [expanded]`, … | unchanged | | sidebar trigger | `button "Toggle sidebar" [expanded]` | unchanged | | buttons with an empty name (task list, app landing, drawer) | 0 | 0 | <details><summary>Local gates on head <code>48dc405d</code> (full record: seat project files <code>card-32159/gates-48dc405d.txt</code>)</summary> - `dispatch-gates --commands` derived list: 36 of 36 exit 0 (34 on the first merge head `24389682`, plus `pnpm --dir ui exec vitest run scripts/` and `pnpm check:type-check-debt` there). The second merge of `origin/main` touched none of this PR's files; the 6 touched test files were re-run on `48dc405d`: 43 / 43 pass. - Not derived, ordered: `check-sdui-manifest` 0, `ui check:spec-symbols` 0, `ui check:new-line-citations` 0 (0 new citations). - `@object-ui/app-shell type-check` 0. - App-shell tests NARROWED: 284 files (all of `layout/__tests__` plus every `ui` test importing `InboxPopover`, `UnifiedSidebar`, `AppHeader`, `ConsoleLayout`, the `global:notifications` renderer or `useInboxBell`), 2,594 tests pass. The full 2,227-file suite did not finish in 60 min on this container; CI Test UI runs it. - NOT MEASURED locally: `ui check:eager-closure` (no console build). This diff changes no locale pack: `en.ts` +0 bytes. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01J8VVAnRYaNVchvKwzetwxo)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 91d88ec commit c0d6406

9 files changed

Lines changed: 139 additions & 8 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
fix(app-shell): the inbox bell's accessible name says how many items are waiting, and the console sidebar is a navigation landmark
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
- **Inbox bell.** Its accessible name was "Open inbox" whatever the badge showed, so a screen reader never heard the count. It is now "Notifications", followed by each non-zero addend of the badge in the same plural forms as the popover's breakdown: "Notifications, 3 unread topics", "Notifications, 1 unread topic, 2 pending approvals". With nothing waiting it is "Notifications". The badge and the "Inbox" tooltip look the same. Tests or scripts that find the bell by the name "Open inbox" now find it by "Notifications". This applies to the header bell and to the `global:notifications` page block, which draw the same control.
11+
- **Sidebar landmark.** The console sidebar's entries now sit in one `nav` landmark labelled "App navigation" (the existing `console.nav.menuLabel` string), on desktop and inside the phone drawer once it opens, so assistive tech can jump to it. Nothing visible changes.
12+
13+
No new translation strings: both names reuse strings every locale pack already carries.

‎ui/packages/app-shell/src/layout/InboxPopover.tsx‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,19 @@ export function InboxPopover({
195195
const unreadTopics = allGroups.reduce((sum, g) => sum + (g.unreadCount > 0 ? 1 : 0), 0);
196196

197197
const totalBadge = unreadTopics + pendingApprovalsCount;
198-
const ariaLabel = t('sidebar.inboxAriaLabel', { defaultValue: 'Open inbox' }) as string;
198+
// The bell's accessible name carries what its badge says: the badge is
199+
// content inside a named button, so a screen reader never reads it. Each
200+
// non-zero addend is spelled out with the plural forms the popover's own
201+
// breakdown uses, so the name explains the sum rather than restating it.
202+
const ariaLabel = [
203+
t('sidebar.notifications', { defaultValue: 'Notifications' }) as string,
204+
...(unreadTopics > 0
205+
? [t('notifications.badgeNotifications', { defaultValue: '{{count}} unread topics', count: unreadTopics }) as string]
206+
: []),
207+
...(pendingApprovalsCount > 0
208+
? [t('notifications.badgeApprovals', { defaultValue: '{{count}} pending approvals', count: pendingApprovalsCount }) as string]
209+
: []),
210+
].join(', ');
199211

200212
// Pulse the bell once whenever the unread/approval pressure increases.
201213
// We track the previous total in a ref so the very first render (when

‎ui/packages/app-shell/src/layout/UnifiedSidebar.tsx‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,14 @@ export function UnifiedSidebar({ activeAppName, railOverlay = false }: UnifiedSi
598598
</SidebarHeader>
599599
)}
600600
<SidebarContent className={`pt-2 ${ICON_RAIL_SCROLLS_VERTICALLY}`}>
601-
<div className="transition-opacity duration-200 ease-in-out">
601+
{/* The sidebar's one navigation landmark, so assistive tech can jump
602+
to it. The `Sidebar` primitive draws a plain `div` (and a dialog on
603+
a phone) and is Shadcn-synced, so the landmark rides inside its
604+
content slot, where it reaches the drawer as well. */}
605+
<nav
606+
aria-label={t('console.nav.menuLabel', { defaultValue: 'App navigation' })}
607+
className="transition-opacity duration-200 ease-in-out"
608+
>
602609
{context === 'app' && activeApp ? (
603610
<>
604611
{/* App-level context selectors (e.g. package scope) */}
@@ -800,7 +807,7 @@ export function UnifiedSidebar({ activeAppName, railOverlay = false }: UnifiedSi
800807
)}
801808
</>
802809
)}
803-
</div>
810+
</nav>
804811
</SidebarContent>
805812
{/* "Keep sidebar open" turns the fold off for this browser; offered
806813
where the fold applies, while the rail is expanded or kept open. */}

‎ui/packages/app-shell/src/layout/__tests__/InboxPopover.badgePlural-13133.test.tsx‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,40 @@ describe('InboxPopover — badge breakdown agrees in number (objectui#13133)', (
9999
expect(screen.getByText('1 pending approval', { selector: 'div' })).toBeInTheDocument();
100100
});
101101
});
102+
103+
/**
104+
* The bell's accessible name carries its count. The badge is content inside a
105+
* button that has an `aria-label`, so it is never part of the name a screen
106+
* reader announces; the name spells out each non-zero addend instead, in the
107+
* same plural forms as the breakdown above.
108+
*/
109+
describe('InboxPopover — the bell is named "Notifications" with its count', () => {
110+
// This harness draws the popover body unconditionally, and its tabs are
111+
// plain buttons here, so a "Notifications" tab shares the bell's bare name;
112+
// the bell is the one carrying the "Inbox" tooltip.
113+
const bell = (name: string) => {
114+
const [match, ...rest] = screen.getAllByRole('button', { name }).filter((b) => b.title === 'Inbox');
115+
expect(rest).toHaveLength(0);
116+
return match;
117+
};
118+
119+
it('names three unread topics in the plural', () => {
120+
renderPopover(3, 0);
121+
expect(bell('Notifications, 3 unread topics')).toBeInTheDocument();
122+
});
123+
124+
it('names one unread topic in the singular', () => {
125+
renderPopover(1, 0);
126+
expect(bell('Notifications, 1 unread topic')).toBeInTheDocument();
127+
});
128+
129+
it('names pending approvals beside the unread topics', () => {
130+
renderPopover(3, 1);
131+
expect(bell('Notifications, 3 unread topics, 1 pending approval')).toBeInTheDocument();
132+
});
133+
134+
it('PRESERVATION: with nothing waiting the bell is named "Notifications" alone', () => {
135+
renderPopover(0, 0);
136+
expect(bell('Notifications')).toBeInTheDocument();
137+
});
138+
});

‎ui/packages/app-shell/src/layout/__tests__/InboxPopover.openingTab-11698.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function bell(inbox: Inbox) {
8484
);
8585
}
8686

87-
const trigger = () => screen.getByRole('button', { name: 'Open inbox' });
87+
const trigger = () => screen.getByRole('button', { name: /^Notifications(,|$)/ });
8888

8989
/** Click the bell open and report the selected tab and the visible panel text. */
9090
function open(): { selected: string; panel: string } {

‎ui/packages/app-shell/src/layout/__tests__/InboxPopover.phoneWidth-29076.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function bell(pendingApprovalsCount: number) {
6060
}
6161

6262
function openInbox() {
63-
fireEvent.click(screen.getByRole('button', { name: 'Open inbox' }));
63+
fireEvent.click(screen.getByRole('button', { name: /^Notifications(,|$)/ }));
6464
return screen.getByRole('dialog');
6565
}
6666

‎ui/packages/app-shell/src/layout/__tests__/LocalizedSidebarTrigger.appBar-12429.test.tsx‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,36 @@ describe('phone: the same trigger opens the drawer, and the drawer carries none
192192
expect(document.querySelector('[data-mobile="true"] [data-sidebar="footer"]')).toBeNull();
193193
});
194194
});
195+
196+
/**
197+
* The sidebar is one navigation landmark, labelled by the shell, so assistive
198+
* tech can jump to it; and the trigger that opens it keeps its name and its
199+
* state at every width. One landmark per open view: the desktop sidebar, or
200+
* the phone drawer once it opens, never one nested in another.
201+
*/
202+
describe('the sidebar is the shell\'s navigation landmark, and its trigger is named', () => {
203+
it('desktop: exactly one landmark, "App navigation", holding the entries', () => {
204+
renderShell(1280);
205+
const navs = screen.getAllByRole('navigation');
206+
expect(navs).toHaveLength(1);
207+
expect(navs[0]).toHaveAccessibleName('App navigation');
208+
expect(within(navs[0]).getByRole('link', { name: 'Leads' })).toBeInTheDocument();
209+
expect(document.querySelectorAll('nav nav')).toHaveLength(0);
210+
});
211+
212+
it('phone: the named trigger opens the drawer, and the drawer holds the one landmark', async () => {
213+
renderShell(375);
214+
const toggle = screen.getByRole('button', { name: 'Toggle sidebar', expanded: false });
215+
// The drawer is not drawn while closed, so neither is its landmark.
216+
expect(screen.queryAllByRole('navigation')).toHaveLength(0);
217+
218+
fireEvent.click(toggle);
219+
const nav = await screen.findByRole('navigation', { name: 'App navigation' });
220+
expect(screen.getAllByRole('navigation')).toHaveLength(1);
221+
expect(within(nav).getByRole('link', { name: 'Leads' })).toBeInTheDocument();
222+
expect(document.querySelectorAll('nav nav')).toHaveLength(0);
223+
// The open drawer is modal, so the app bar is hidden from the role tree;
224+
// the trigger keeps its name and reports the drawer open.
225+
expect(screen.getByRole('button', { name: 'Toggle sidebar', expanded: true, hidden: true })).toBe(toggle);
226+
});
227+
});

‎ui/packages/app-shell/src/layout/__tests__/UnifiedSidebar.groupDefaultOpen-13336.test.tsx‎

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import '@testing-library/jest-dom/vitest';
2020
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2121
import React from 'react';
22-
import { cleanup, render, screen } from '@testing-library/react';
22+
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react';
2323
import { MemoryRouter } from 'react-router-dom';
2424
import type { NavigationItem } from '@object-ui/types';
2525

@@ -153,3 +153,32 @@ describe('UnifiedSidebar — a group opens unless it declares otherwise (objectu
153153
expect(screen.getByRole('link', { name: 'advanced 3' })).toBeInTheDocument();
154154
});
155155
});
156+
157+
/**
158+
* A group's disclosure is named by the group's label and reports its state,
159+
* so it is never an unnamed icon button: the chevron and a collapsed group's
160+
* entry count stay out of its name.
161+
*/
162+
describe('UnifiedSidebar — a group disclosure is named by its label and reports open or closed', () => {
163+
it('a collapsed group is "Advanced", not expanded, and its count badge is not in the name', () => {
164+
renderSidebar();
165+
expect(screen.getByRole('button', { name: 'Advanced', expanded: false })).toBeInTheDocument();
166+
});
167+
168+
it('clicking it opens and closes the group under the same name', () => {
169+
renderSidebar();
170+
fireEvent.click(screen.getByRole('button', { name: 'Advanced', expanded: false }));
171+
expect(screen.getByRole('button', { name: 'Advanced', expanded: true })).toBeInTheDocument();
172+
expect(screen.getByRole('link', { name: 'advanced 1' })).toBeInTheDocument();
173+
174+
fireEvent.click(screen.getByRole('button', { name: 'Advanced', expanded: true }));
175+
expect(screen.getByRole('button', { name: 'Advanced', expanded: false })).toBeInTheDocument();
176+
});
177+
178+
it('every group disclosure sits inside the sidebar\'s one navigation landmark', () => {
179+
renderSidebar();
180+
const nav = screen.getByRole('navigation', { name: 'App navigation' });
181+
expect(within(nav).getByRole('button', { name: 'Configuration', expanded: true })).toBeInTheDocument();
182+
expect(within(nav).getByRole('button', { name: 'Advanced', expanded: false })).toBeInTheDocument();
183+
});
184+
});

‎ui/packages/app-shell/src/views/__tests__/global-page-blocks.render.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ describe('objectui#6757 — spec `PageComponentType` members that had no rendere
245245
renderPage('global:notifications');
246246

247247
// 1. Real content: the bell control, with its accessible name.
248-
const bell = await screen.findByRole('button', { name: 'Open inbox' });
248+
const bell = await screen.findByRole('button', { name: /^Notifications(,|$)/ });
249249
expect(bell).toBeInTheDocument();
250250

251251
// 2. Real content that had to travel the data path: two unread rows on
@@ -263,7 +263,7 @@ describe('objectui#6757 — spec `PageComponentType` members that had no rendere
263263

264264
it('opens the inbox and lists the rows the feed returned', async () => {
265265
renderPage('global:notifications');
266-
const bell = await screen.findByRole('button', { name: 'Open inbox' });
266+
const bell = await screen.findByRole('button', { name: /^Notifications(,|$)/ });
267267
await waitFor(() => expect(bell).toHaveTextContent('2'));
268268

269269
fireEvent.click(bell);

0 commit comments

Comments
 (0)