(e: KeyboardEvent)
| 38 | ); |
| 39 | |
| 40 | const handleKeyDown = (e: KeyboardEvent) => { |
| 41 | if (e.key !== "Tab") return; |
| 42 | const els = focusable(); |
| 43 | if (els.length === 0) return; |
| 44 | |
| 45 | const first = els[0]; |
| 46 | const last = els[els.length - 1]; |
| 47 | |
| 48 | if (e.shiftKey) { |
| 49 | if (document.activeElement === first) { |
| 50 | e.preventDefault(); |
| 51 | last.focus(); |
| 52 | } |
| 53 | } else { |
| 54 | if (document.activeElement === last) { |
| 55 | e.preventDefault(); |
| 56 | first.focus(); |
| 57 | } |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | // Move focus into the trap on mount |
| 62 | const els = focusable(); |
nothing calls this directly
no test coverage detected