← back to open source
JavaScript · MIT · v1.1.0

focus-loop

A dependency-free focus trap for modals and drawers, tested against real screen readers rather than assumptions about them.

★ 190 stars⑂ 14 forksupdated 2026.03

Overview

focus-loop keeps keyboard focus inside an open modal and restores it correctly on close. Extracted from a client project after fixing the same accessibility bug for the third time.

Why it exists

Focus trapping looks trivial until you test it with an actual screen reader, at which point most implementations fall apart.

Roadmap

  • Better support for nested modals
  • Automated axe-core test suite

Release history

v1.1.0
2026.03.30
Fixed nested-modal focus restoration.
v1.0.0
2025.10.06
Initial release.