Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)75k · #2851

focus-order

Skill này làm gì

Skill này kiểm tra thứ tự focus bàn phím di chuyển qua trang. Skill dành cho lập trình viên muốn người dùng bàn phím di chuyển mượt mà qua nội dung.

Khi nào nên dùng

  • ✓Khi bấm Tab khiến con trỏ nhảy lung tung trên trang một cách khó hiểu.
  • ✓Khi trang của bạn dùng các giá trị tabindex dương mà bạn muốn bỏ.
  • ✓Khi hộp thoại đóng nhưng focus không quay về đúng chỗ.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/focus-order/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể kiểm tra thứ tự Tab trên trang của tôi có hợp lý không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent xem lại thứ tự HTML và các giá trị tabindex đang dùng. Agent gợi ý sắp xếp đánh dấu cho khớp với bố cục hiển thị và tránh các số tabindex dương.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

Câu hỏi thường gặp

Vì sao thứ tự Tab lại quan trọng?

Người dùng bàn phím phụ thuộc vào thứ tự có thể đoán trước để di chuyển hiệu quả qua trang.

Có nên dùng CSS để di chuyển các phần tử không?

Skill khuyên dùng CSS để định vị hiển thị, thay vì sắp xếp lại HTML.

tabindex 0 và -1 nghĩa là gì?

Skill nói 0 đưa một phần tử tùy chỉnh vào thứ tự Tab, còn -1 chỉ cho phép focus từ mã.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2851
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự