跳到正文
Skillpedia
网站与界面(前端)75k · #2851

focus-order

它能做什么

这项技能检查键盘焦点在页面中移动的顺序。适用于希望键盘用户能顺畅浏览内容的开发者。

适用场景

  • ✓当按 Tab 键时,焦点以令人困惑的方式在页面中跳动的时候。
  • ✓当页面使用了你想要移除的正值 tabindex 的时候。
  • ✓当对话框关闭后焦点没有回到正确位置的时候。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/focus-order/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/focus-order/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请检查我页面的 Tab 顺序是否合理。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查 HTML 的顺序以及所使用的任何 tabindex 值。它会建议调整标记,使其与视觉布局一致,并避免使用正值的 tabindex 数字。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Ensure logical focus order

When focus jumps unexpectedly, keyboard users get disoriented and can't find content—mismatched visual and focus order makes navigation impossible.

Quick Reference

  • Tab order should match visual reading order (left-to-right, top-to-bottom)
  • DOM order determines tab order—arrange HTML to match visual layout
  • Never use positive tabindex values (1, 2, 3)—they break natural flow
  • Use CSS for visual positioning, not DOM reordering

Check

Tab through the page and verify focus moves in a logical sequence matching visual layout. Check that modals trap focus appropriately, and focus returns to triggering elements when dialogs close.

Fix

Order DOM elements to match visual layout. Avoid positive tabindex values which override natural order. Use tabindex='0' for custom interactive elements and tabindex='-1' for programmatic focus management.

Explain

Explain how keyboard users rely on predictable tab order to navigate efficiently, and why mismatched visual and focus order creates confusion and reduces usability for assistive technology users.

Code Review

Review the rendered markup and interactive states that affect Ensure logical focus order. 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/focus-order

常见问题

Tab 顺序为什么重要?

键盘用户依赖可预测的顺序来高效地浏览页面。

我应该用 CSS 移动元素吗?

这项技能推荐使用 CSS 进行视觉定位,而不是重新排列 HTML。

tabindex 0 和 -1 是什么意思?

这项技能说明,0 会使自定义元素加入 Tab 顺序,而 -1 只允许由代码获得焦点。

详情

作者的原始描述

Use when reviewing rendered HTML, interactive components, or design-system patterns related to Ensure logical focus order. Check native semantics first, then inspect keyboard behavior, focus flow, accessible names, and screen-reader output where relevant.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2851
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能