fix: check document.activeElement in addition to event.target for ignoreInputs#89
fix: check document.activeElement in addition to event.target for ignoreInputs#89KevinVandy wants to merge 3 commits intomainfrom
Conversation
…oreInputs Some libraries like React Aria's Autocomplete intercept keydown events from input elements and re-dispatch them on a different element (like a list item). In these cases, event.target is the re-dispatched target, not the actual focused input. By also checking document.activeElement, we can properly detect when the user is typing in an input even if the event has been re-dispatched. Fixes #83 Co-authored-by: kevinvandy656 <kevinvandy656@gmail.com>
Co-authored-by: kevinvandy656 <kevinvandy656@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughThe change fixes the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 Changeset Version Preview1 package(s) bumped directly, 11 bumped as dependents. 🟩 Patch bumps
|
@tanstack/angular-hotkeys
@tanstack/hotkeys
@tanstack/hotkeys-devtools
@tanstack/preact-hotkeys
@tanstack/preact-hotkeys-devtools
@tanstack/react-hotkeys
@tanstack/react-hotkeys-devtools
@tanstack/solid-hotkeys
@tanstack/solid-hotkeys-devtools
@tanstack/svelte-hotkeys
@tanstack/vue-hotkeys
@tanstack/vue-hotkeys-devtools
commit: |
🎯 Changes
This PR fixes the
ignoreInputsoption not working properly with libraries like React Aria that intercept and re-dispatch keyboard events.Problem:
Some libraries like React Aria's Autocomplete intercept
keydownevents from input elements and re-dispatch them on a different element (like a list item in a collection). In these cases,event.targetis the re-dispatched target (e.g., a list item), not the actual focused input. This causes TanStack Hotkeys to incorrectly trigger hotkeys even though the user is typing in an input.Solution:
In addition to checking
event.target, we now also checkdocument.activeElementto detect if the user is actually focused on an input element. This ensures that theignoreInputsoption works correctly even when events are re-dispatched by libraries like React Aria.Changes:
HotkeyManager.#processTargetEvent()to check bothevent.targetanddocument.activeElementviaisInputElement()SequenceManager.#processTargetEvent()with the same fixFixes #83
✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
ignoreInputsoption to properly detect input focus even when keyboard events are dispatched from different elements (e.g., in React Aria patterns).Tests
Documentation