Skip to content

Commit

Permalink
JohannesKlauss#276 Added default filters instance
Browse files Browse the repository at this point in the history
This fixes the issue of globally scoped filters
  • Loading branch information
f-ricci authored Jun 15, 2020
1 parent 07d0b95 commit cf565fc
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export function useHotkeys(keys: string, callback: KeyHandler, options?: any[] |
const memoisedCallback = useCallback(callback, deps || []);

useEffect(() => {
// default instance to avoid globally scoped filters, see #276
hotkeys.filter = () => Boolean(true)

if (options && (options as Options).enableOnTags) {
hotkeys.filter = ({target, srcElement}) => {
// @ts-ignore
Expand Down

0 comments on commit cf565fc

Please sign in to comment.