Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass event to handler callback in useOutsideClick
Browse files Browse the repository at this point in the history
lolmaus authored Dec 17, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 19ca365 commit 6f94a90
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hooks/useOutsideClick/useOutsideClick.tsx
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import React from 'react';

export interface UseOutsideClickProps<T> {
ref: React.RefObject<T>;
handler?: () => void;
handler?: (e: MouseEvent | TouchEvent) => void;
}

type UseOutsideClickType = <K extends HTMLElement>(props: UseOutsideClickProps<K>) => void;
@@ -21,7 +21,7 @@ export const useOutsideClick: UseOutsideClickType = ({ref, handler}) => {
const elem = ref?.current;

if (elem && !elem.contains(e.target as Node) && handler) {
handler();
handler(e);
}
};

0 comments on commit 6f94a90

Please sign in to comment.