Closed artchen-db closed 6 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
react-hotkeys-hook | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Dec 27, 2023 1:17am |
Thank you for your contribution!
Problem
The intended element that receives the focus might be inside a shadow root. In such case the correct check for active element should be against the closest
ShadowRoot.activeElement
.Example sandbox: https://codesandbox.io/p/sandbox/react-hotkeys-hook-shadow-root-focus-trap-cpp7kj
Solution
Instead of assuming document.activeElement, find the closest root node from ref.current first.