diff --git a/frontend/src/app/layout/AppSider.tsx b/frontend/src/app/layout/AppSider.tsx index 396d9c7..b752e2b 100644 --- a/frontend/src/app/layout/AppSider.tsx +++ b/frontend/src/app/layout/AppSider.tsx @@ -7,8 +7,13 @@ * 子菜单自动变浮层,label 走 Tooltip,不用页面配合。 * · 选中态:以前是 inset box-shadow 画一条 2px 竖线;Menu 的 * itemSelectedBg / itemSelectedColor 是 token,两套主题一起跟着变。 - * · 可达性:NavLink 手写的 aria-current、键盘方向键、子菜单展开折叠, - * Menu 自带(role=menu + roving tabindex),不必再自证。 + * · 可达性:键盘方向键、子菜单展开折叠、role=menu + roving tabindex 是 Menu 自带的。 + * **但「当前页面」这件事它不带**(2026-11-08 真机 VoiceOver + CDP 双查, + * reports/ui_evidence/nex-p8f/05-nav/probe-output.txt C 段与 + * ../07-screen-reader/README.md §4 AT-2):选中项只有 `.ant-menu-item-selected` + * 这个类,`li[role=menuitem]` 上没有 aria-current / aria-selected + * (rc-menu 只在 role=option 那条分支写 aria-selected),读屏因此只报「菜单」 + * 不报「当前页面」。所以这一条得自己补,见下面 currentMark()。 * * 结构(**只到两级**,这是产品定的口径,别再往深里加): * 一级 = 全局三项 + 「项目环节」;二级 = 七个环节。 @@ -66,9 +71,16 @@ export function AppNavMenu({ projectId, collapsed = false, onNavigate }: { const [openKeys, setOpenKeys] = useState(projectId ? [PROJECT_KEY] : []) useEffect(() => { if (projectId) setOpenKeys((keys) => (keys.includes(PROJECT_KEY) ? keys : [...keys, PROJECT_KEY])) }, [projectId]) + /* 当前路由那一项补 aria-current="page"(选中态的唯一凭据就是 pathname,跟 selectedKeys 同源)。 + rc-menu 把 item 对象上除 label/children/key/type/extra 之外的字段原样转给 MenuItem, + MenuItem 再 omit(['extra']) 之后整包铺到
  • 上(node_modules/rc-menu/es/utils/nodeUtil.js + 的 _excluded、MenuItem.js:168),所以这个属性落得进 DOM —— 真机验证见 + reports/ui_evidence/nex-p8f/05-nav/probe-output.txt C 段。 */ + const currentMark = (key: string) => (key === pathname ? { 'aria-current': 'page' as const } : {}) + const items = useMemo(() => { const list: MenuProps['items'] = globalNav.map((m) => ({ - key: pathOf(m, ''), icon: m.icon, label: m.label, title: m.label + key: pathOf(m, ''), icon: m.icon, label: m.label, title: m.label, ...currentMark(pathOf(m, '')) })) if (projectId) { list.push({ @@ -86,12 +98,13 @@ export function AppNavMenu({ projectId, collapsed = false, onNavigate }: { 展开态把它写成原生 title 属性,收起态拿它当 Tooltip 文案, 不用再拿 顶一层(那样两头的行为都会退化成裸文本)。 */ label: m.label, - title: m.hint ? `${m.label}:${m.hint}` : m.label + title: m.hint ? `${m.label}:${m.hint}` : m.label, + ...currentMark(pathOf(m, projectId)) })) }) } return list - }, [projectId]) + }, [projectId, pathname]) return (