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

autofocus-avoidance

Skill này làm gì

Skill này kiểm tra xem việc tải trang có chuyển tiêu điểm vào ô form một cách bất ngờ hay không. Skill dành cho lập trình viên xây trang có form nằm bên dưới các nội dung khác.

Khi nào nên dùng

  • ✓Khi trang có ô form với autofocus nằm dưới tiêu đề hoặc đoạn giới thiệu.
  • ✓Khi người dùng trình đọc màn hình báo rằng họ bị đưa vào giữa trang.
  • ✓Khi bạn rà soát trang đăng nhập hoặc tìm kiếm có dùng autofocus.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/autofocus-avoidance/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/autofocus-avoidance/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

“Hãy bỏ autofocus khỏi form liên hệ trên trang dịch vụ của tôi để người dùng trình đọc màn hình bắt đầu từ đầu trang.”

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

Cách hoạt động

Agent tìm thuộc tính autofocus trên các phần tử form rồi xóa đi, hoặc chỉ đặt tiêu điểm bằng JavaScript sau khi người dùng thực hiện một hành độ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.

Avoid autofocus on form fields

Autofocus teleports screen reader users to mid-page without context—they miss everything before the form and have no idea where they landed.

Quick Reference

  • Avoid autofocus on pages with content before the form
  • Autofocus disrupts screen reader users who lose page context
  • Use JavaScript focus after user interaction instead of page load
  • Login and search-only pages are exceptions where autofocus may be acceptable

Check

Search for autofocus attributes on form elements. Verify that page load does not unexpectedly move focus away from the page top, especially on pages with content before the form.

Fix

Remove autofocus attributes from form elements. If focus management is needed, use JavaScript to set focus after user interaction rather than automatically on page load.

Explain

Explain how autofocus moves screen reader users to mid-page without context, can trigger unexpected scrolling, and disrupts users who were reading content before the focused element.

Code Review

Review the rendered markup and interactive states that affect Avoid autofocus on form fields. 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/autofocus-avoidance

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

Vì sao autofocus là vấn đề?

Skill nói người dùng trình đọc màn hình mất ngữ cảnh của mọi thứ trước form và không biết mình đang ở đâu.

Có lúc nào autofocus là ổn không?

Có. Skill nói các trang chỉ có đăng nhập hoặc tìm kiếm có thể là ngoại lệ.

Vậy nên đặt tiêu điểm bằng cách nào?

Bằng JavaScript, sau khi người dùng tương tác với trang.

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 Avoid autofocus on form fields. 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
#2750
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ự