aria-hidden-focus
它能做什么
这项技能检查位于隐藏容器内的可聚焦元素。适合隐藏面板或菜单、并需要键盘焦点正确运作的开发者。
适用场景
- ✓当面板用 aria-hidden 隐藏,但其中的链接或按钮仍可通过 Tab 键访问时。
- ✓当键盘用户反映焦点消失在空处时。
- ✓当你审查折叠或移出屏幕的内容时。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/aria-hidden-focus/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的侧边菜单用 aria-hidden 隐藏了,但人们仍然可以用 Tab 键进入。请修复这个问题。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找出 aria-hidden 容器内的可聚焦子元素,并把它们的 tabindex 设为 -1,或使用 inert 属性阻止其获得焦点。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Remove focusable elements from aria-hidden containers
When a keyboard user tabs into an aria-hidden element, the screen reader remains silent, leaving the user with no idea where their focus is or what they can interact with.
Quick Reference
- Elements with
aria-hidden="true"must not contain focusable children - Focusing on a hidden element creates a 'ghost' focus for screen reader users
- Use
tabindex="-1"orinertto properly hide interactive elements
Check
Scan aria-hidden="true" containers for focusable elements like links, buttons, or inputs.
Fix
Add tabindex="-1" to focusable children inside aria-hidden containers or use the inert attribute.
Explain
Explain why focusable elements inside aria-hidden containers cause confusion for keyboard and screen reader users.
Code Review
Review the rendered markup and interactive states that affect Remove focusable elements from aria-hidden containers. Flag exact elements, roles, labels, focus behavior, or keyboard interactions that violate the rule, and note how to verify the fix with browser accessibility tooling or assistive tech.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/accessibility/aria-hidden-focus
常见问题
焦点落在隐藏元素内会出现什么问题?
这项技能说明,屏幕阅读器用户听不到任何内容,因而不知道自己身在何处。
什么是 inert 属性?
它是一个 HTML 属性,可以让某个区域无法获得键盘焦点,这项技能把它作为一种选择提供。
这项技能列出了哪些修复方法?
它列出了将 tabindex 设为 -1,以及使用 inert 属性,作为隐藏交互元素的两种方式。
详情
作者的原始描述
Use when reviewing rendered HTML, interactive components, or design-system patterns related to Remove focusable elements from aria-hidden containers. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.
热度
- GitHub 星标
- 75k
- 排名
- #2728
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。