From 2821475eacf8b217a04ebad28491bb77346c2ce1 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Sun, 8 Nov 2026 14:50:16 +0800 Subject: [PATCH] =?UTF-8?q?NEX=20=E9=98=B6=E6=AE=B5=208.5=C2=B7=E7=AC=AC5?= =?UTF-8?q?=E9=A1=B9=EF=BC=9A=E5=AF=BC=E8=88=AA=E4=B8=A4=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=85=A5=E5=86=8C=20+=20=E5=BD=93=E5=89=8D=E9=A1=B5=E5=AF=B9?= =?UTF-8?q?=E8=BE=85=E5=8A=A9=E6=8A=80=E6=9C=AF=E5=8F=AF=E8=A7=81=EF=BC=88?= =?UTF-8?q?aria-current=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 批准书 §5 的决策是「保持现有分离设计」,所以**两条状态本身一行代码都没改**: 桌面折叠走 `useLocalStorage`(reload 后 `ls="true"`、侧栏 63 px,实测守住), 移动端抽屉开合走 `useState`(`localStorage` 键集为空、reload 后 `open:false`)。 为什么不合并成一条 Boolean,理由写进 `docs/UI规范.md` §6.2.1:折叠是**偏好** (用户按住的那把尺子,跨会话有效,丢了每次开机都要重展开),抽屉是**一次性动作** (读完当前这条就该关掉,持久化会让下次进站内先撞一块挡住正文的板子); 两者生命周期不同,共用一条状态等于让手机用户替桌面用户付账。 顺手关掉本轮实测抓到的真实缺口 AT-2:选中项只有 `.ant-menu-item-selected` 这个类, `li[role=menuitem]` 上没有 aria-current / aria-selected(rc-menu 只在 role=option 分支写 aria-selected),VoiceOver 因此只报「菜单」不报「当前页面」。补 `currentMark(key)` 给 当前路由那一项写 `aria-current="page"`,并把 `useMemo` 依赖补上 `pathname` (少一项就会在换页后把标记留在旧项上,选中态与标记同源才谈得上「一致」)。 文件头那句「可达性 Menu 自带,不必再自证」是错的,一并改成实测结论 + 证据路径。 验证:三条路由 + 抽屉内**有且只有当前项**带 `aria-current`,菜单宽度 207 未变(没挤出 新视觉);折叠成图标轨时二级项不渲染 → 折叠档 AT 仍读不到当前页,弹层展开后恢复, 这条边界写进规范并登记 S-4。VoiceOver 是否真播报「当前页面」未复听 → AT-2′。 --- frontend/src/app/layout/AppSider.tsx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) 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 (